febus982/cloudevents-pydantic

View on GitHub
Improve nested Binary support #19
Federico Busetti authored 17bfb6be
complete00:00:16
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
docker pull codeclimate/codeclimate-sonar-python:b10
b10: Pulling from codeclimate/codeclimate-sonar-python
709515475419: Pulling fs layer
d1c225ed7c34: Pulling fs layer
887f300163b6: Pulling fs layer
a3ed95caeb02: Pulling fs layer
9b412187b352: Pulling fs layer
a3ed95caeb02: Waiting
8fe915fa1948: Pulling fs layer
9b412187b352: Waiting
65145a386a45: Pulling fs layer
a64dfb9c0f27: Pulling fs layer
59a464ab5a51: Pulling fs layer
47413513c002: Pulling fs layer
9f30da6d3676: Pulling fs layer
8fe915fa1948: Waiting
a64dfb9c0f27: Waiting
59a464ab5a51: Waiting
65145a386a45: Waiting
47413513c002: Waiting
9f30da6d3676: Waiting
d1c225ed7c34: Verifying Checksum
d1c225ed7c34: Download complete
709515475419: Verifying Checksum
709515475419: Download complete
a3ed95caeb02: Download complete
709515475419: Pull complete
9b412187b352: Verifying Checksum
9b412187b352: Download complete
d1c225ed7c34: Pull complete
65145a386a45: Download complete
887f300163b6: Verifying Checksum
887f300163b6: Download complete
59a464ab5a51: Verifying Checksum
59a464ab5a51: Download complete
887f300163b6: Pull complete
8fe915fa1948: Verifying Checksum
8fe915fa1948: Download complete
a3ed95caeb02: Pull complete
9b412187b352: Pull complete
47413513c002: Verifying Checksum
47413513c002: Download complete
a64dfb9c0f27: Verifying Checksum
a64dfb9c0f27: Download complete
9f30da6d3676: Verifying Checksum
9f30da6d3676: Download complete
8fe915fa1948: Pull complete
65145a386a45: Pull complete
a64dfb9c0f27: Pull complete
59a464ab5a51: Pull complete
47413513c002: Pull complete
9f30da6d3676: Pull complete
Digest: sha256:7904831e83e5474cba8a95726a691787d74d669d74a8721f114057ebb4a8943d
Status: Downloaded newer image for registry.prod.codeclimate.net/codeclimate/codeclimate-sonar-python:b10
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-28T13:45:56.139211 #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-28T13:45:56.139260 #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 33
    def to_json(event: CloudEvent) -> str:
                     ^
SyntaxError: invalid syntax


I, [2024-09-28T13:45:56.153105 #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-28T13:45:56.165082 #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-28T13:45:56.175826 #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-28T13:45:56.192218 #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:

   36: cloudevents_pydantic.formats import json
   37: 
   38: _T = TypeVar("_T", bound=CloudEvent, default=CloudEvent)
   39: 
   40: 
   41: class HTTPComponents(NamedTuple):
  -->      headers: Dict[str, str]
   43:     body: str
   44: 
   45: 
   46: class HTTPHandler(Generic[_T]):
   47:     event_class: Type[_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.221s
INFO: Final Memory: 6M/295M
INFO: ------------------------------------------------------------------------