febus982/cloudevents-pydantic

View on GitHub
Update docs #21
Federico Busetti authored 02699d61
complete00:00:12
1
git clone
2
codeclimate validate-config
View output
codeclimate validate-config
No errors or warnings found in .codeclimate.yml.
3
codeclimate prepare
View output
codeclimate prepare
4
builder pull-engines
View output
determining required images
5
structure
View output
12
Parser process id: 12
codeclimate-parser socket not present
waiting 1s...
6
duplication
View output
12
Parser process id: 12
codeclimate-parser socket not present
waiting 1s...
I, [2024-09-28T16:52:32.816408 #1]  INFO -- : Skipping file ./cloudevents_pydantic/formats/json.py due to exception (CC::Engine::Analyzers::ParserError): `python2 /usr/src/app/lib/cc/engine/analyzers/python/parser.py` exited with code 1:
Traceback (most recent call last):
  File "/usr/src/app/lib/cc/engine/analyzers/python/parser.py", line 51, in <module>
    print(json.dumps(to_json(ast.parse(source))))
  File "/usr/local/python2/lib/python2.7/ast.py", line 37, in parse
    return compile(source, filename, mode, PyCF_ONLY_AST)
  File "<unknown>", line 32
    def to_json(event: CloudEvent) -> str:
                     ^
SyntaxError: invalid syntax


I, [2024-09-28T16:52:32.816479 #1]  INFO -- : Skipping file ./scripts/gen_pages.py due to exception (CC::Engine::Analyzers::ParserError): `python2 /usr/src/app/lib/cc/engine/analyzers/python/parser.py` exited with code 1:
Traceback (most recent call last):
  File "/usr/src/app/lib/cc/engine/analyzers/python/parser.py", line 51, in <module>
    print(json.dumps(to_json(ast.parse(source))))
  File "/usr/local/python2/lib/python2.7/ast.py", line 37, in parse
    return compile(source, filename, mode, PyCF_ONLY_AST)
  File "<unknown>", line 70
    parts = (src_dir, *tuple(module_path.parts))
                      ^
SyntaxError: invalid syntax


I, [2024-09-28T16:52:32.828481 #1]  INFO -- : Skipping file ./cloudevents_pydantic/bindings/http.py due to exception (CC::Engine::Analyzers::ParserError): `python2 /usr/src/app/lib/cc/engine/analyzers/python/parser.py` exited with code 1:
Traceback (most recent call last):
  File "/usr/src/app/lib/cc/engine/analyzers/python/parser.py", line 51, in <module>
    print(json.dumps(to_json(ast.parse(source))))
  File "/usr/local/python2/lib/python2.7/ast.py", line 37, in parse
    return compile(source, filename, mode, PyCF_ONLY_AST)
  File "<unknown>", line 42
    headers: Dict[str, str]
           ^
SyntaxError: invalid syntax


I, [2024-09-28T16:52:32.839860 #1]  INFO -- : Skipping file ./cloudevents_pydantic/events/_event.py due to exception (CC::Engine::Analyzers::ParserError): `python2 /usr/src/app/lib/cc/engine/analyzers/python/parser.py` exited with code 1:
Traceback (most recent call last):
  File "/usr/src/app/lib/cc/engine/analyzers/python/parser.py", line 51, in <module>
    print(json.dumps(to_json(ast.parse(source))))
  File "/usr/local/python2/lib/python2.7/ast.py", line 37, in parse
    return compile(source, filename, mode, PyCF_ONLY_AST)
  File "<unknown>", line 55
    id: Optional[str] = None,
      ^
SyntaxError: invalid syntax


I, [2024-09-28T16:52:32.853233 #1]  INFO -- : Skipping file ./cloudevents_pydantic/events/field_types/_canonic_types.py due to exception (CC::Engine::Analyzers::ParserError): `python2 /usr/src/app/lib/cc/engine/analyzers/python/parser.py` exited with code 1:
Traceback (most recent call last):
  File "/usr/src/app/lib/cc/engine/analyzers/python/parser.py", line 51, in <module>
    print(json.dumps(to_json(ast.parse(source))))
  File "/usr/local/python2/lib/python2.7/ast.py", line 37, in parse
    return compile(source, filename, mode, PyCF_ONLY_AST)
  File "<unknown>", line 37
    def bool_serializer(value: bool) -> str:
                             ^
SyntaxError: invalid syntax


I, [2024-09-28T16:52:32.874117 #1]  INFO -- : Skipping file benchmark.py due to exception (CC::Engine::Analyzers::ParserError): `python2 /usr/src/app/lib/cc/engine/analyzers/python/parser.py` exited with code 1:
Traceback (most recent call last):
  File "/usr/src/app/lib/cc/engine/analyzers/python/parser.py", line 51, in <module>
    print(json.dumps(to_json(ast.parse(source))))
  File "/usr/local/python2/lib/python2.7/ast.py", line 37, in parse
    return compile(source, filename, mode, PyCF_ONLY_AST)
  File "<unknown>", line 51
    data: Binary = Field(Binary, alias="data_base64")
        ^
SyntaxError: invalid syntax
7
sonar-python
sonar-python engine documentation
View output
INFO: Java 1.8.0_111-internal Oracle Corporation (64-bit)
INFO: Linux 4.4.0-1128-aws amd64
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/usr/src/app/build/libs/sonarlint-core-2.17.0.899.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/usr/src/app/build/libs/sonarlint-cli-2.1.0.566.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [ch.qos.logback.classic.util.ContextSelectorStaticBinder]
INFO: Index files
INFO: 30 files indexed
ERROR: Unable to parse file: /code/cloudevents_pydantic/bindings/http.py
ERROR: Parse error at line 42 column 11:

   35: import CloudEvent
   36: from cloudevents_pydantic.formats import json
   37: 
   38: _T = TypeVar("_T", bound=CloudEvent)
   39: 
   40: 
   41: class HTTPComponents(NamedTuple):
  -->      headers: Dict[str, str]
   43:     body: str
   44: 
   45: 
   46: class HTTPHandler(Generic[_T]):
   47:     event_adapter: TypeAdapter[_T]

ERROR: Unable to parse file: /code/cloudevents_pydantic/events/_event.py
ERROR: Parse error at line 58 column 16:

   55: = None,
   56:         specversion: Optional[SpecVersion] = None,
   57:         time: Optional[Union[datetime.datetime, str]] = None,
  -->          **kwargs,
   59:     ) -> "CloudEvent":
   60:         """
   61:         Builds a new CloudEvent using sensible defaults.
   62: 
   63:         :param id: The event id, defaults to a ULID
   64:         :type id: typing.Optional[str]
   65:         :param specversion: The specversion of the event, defaults to 1.0
   66:         :type specversion: typing.Optional[SpecVersion]
   67:         :param time: The time the event occurred, defaults to now
   68:         :type time: typing.Optional[Union[datetime.datetime, str]]
   69:         :param kwargs: Other kwargs forwarded directly to the CloudEvent model.
   70:         :return: A new CloudEvent model
   71:         :rtype: CloudEvent
   72:         """
   73:         return cls(
   74:             id=id or str(ULID()),
   75:             specversion=specversion or DEFAULT_SPECVERSION,

ERROR: Unable to parse file: /code/benchmark.py
ERROR: Parse error at line 51 column 8:

   43: events import CloudEvent
   44: from cloudevents_pydantic.events.field_types import Binary
   45: 
   46: valid_json = '{"data_base64":"dGVzdA==","source":"https://example.com/event-producer","id":"b96267e2-87be-4f7a-b87c-82f64360d954","type":"com.example.string","specversion":"1.0","time":"2022-07-16T12:03:20.519216+04:00","subject":null,"datacontenttype":null,"dataschema":null}'
   47: test_iterations = 1000000
   48: 
   49: 
   50: class BinaryEvent(CloudEvent):
  -->      data: Binary = Field(Binary, alias="data_base64")
   52: 
   53: 
   54: def json_deserialization():
   55:     CloudEvent.model_validate_json(valid_json)
   56: 
   57: 
   58: def json_deserialization_official_sdk_pydantic

INFO: ------------------------------------------------------------------------
INFO: EXECUTION SUCCESS
INFO: ------------------------------------------------------------------------
INFO: Total time: 0.314s
INFO: Final Memory: 6M/295M
INFO: ------------------------------------------------------------------------