febus982/cloudevents-pydantic

View on GitHub
Reusable annotations for composition #23
Federico Busetti authored b32c2914
complete00:00:17
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
8fe915fa1948: Pulling fs layer
65145a386a45: Pulling fs layer
a64dfb9c0f27: Pulling fs layer
59a464ab5a51: Pulling fs layer
47413513c002: Pulling fs layer
9b412187b352: Waiting
9f30da6d3676: Pulling fs layer
59a464ab5a51: Waiting
47413513c002: Waiting
9f30da6d3676: Waiting
8fe915fa1948: Waiting
65145a386a45: Waiting
a3ed95caeb02: Waiting
a64dfb9c0f27: Waiting
d1c225ed7c34: Verifying Checksum
d1c225ed7c34: Download complete
a3ed95caeb02: Download complete
709515475419: Download complete
709515475419: Pull complete
9b412187b352: Verifying Checksum
9b412187b352: Download complete
d1c225ed7c34: Pull complete
65145a386a45: Verifying Checksum
65145a386a45: Download complete
887f300163b6: Verifying Checksum
887f300163b6: Download complete
59a464ab5a51: Verifying Checksum
59a464ab5a51: Download complete
887f300163b6: Pull complete
a3ed95caeb02: Pull complete
8fe915fa1948: Verifying Checksum
8fe915fa1948: Download complete
9b412187b352: Pull complete
47413513c002: Verifying Checksum
47413513c002: Download complete
8fe915fa1948: Pull complete
9f30da6d3676: Verifying Checksum
9f30da6d3676: Download complete
65145a386a45: Pull complete
a64dfb9c0f27: Verifying Checksum
a64dfb9c0f27: Download 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-29T10:21:32.182421 #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-29T10:21:32.182559 #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-29T10:21:32.193679 #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-29T10:21:32.204655 #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 65
    id: Optional[str] = None,
      ^
SyntaxError: invalid syntax


I, [2024-09-29T10:21:32.225775 #1]  INFO -- : Skipping file ./cloudevents_pydantic/events/fields/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-29T10:21:32.258426 #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: 33 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 68 column 16:

   65: = None,
   66:         specversion: Optional[SpecVersion] = None,
   67:         time: Optional[Union[datetime.datetime, str]] = None,
  -->          **kwargs,
   69:     ) -> "CloudEvent":
   70:         """
   71:         Builds a new CloudEvent using sensible defaults.
   72: 
   73:         :param id: The event id, defaults to a ULID
   74:         :type id: typing.Optional[str]
   75:         :param specversion: The specversion of the event, defaults to 1.0
   76:         :type specversion: typing.Optional[SpecVersion]
   77:         :param time: The time the event occurred, defaults to now
   78:         :type time: typing.Optional[Union[datetime.datetime, str]]
   79:         :param kwargs: Other kwargs forwarded directly to the CloudEvent model.
   80:         :return: A new CloudEvent model
   81:         :rtype: CloudEvent
   82:         """
   83:         return cls(
   84:             id=id or str(ULID()),
   85:             specversion=specversion or DEFAULT_SPECVERSION,

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

   43: CloudEvent
   44: from cloudevents_pydantic.events.fields.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.236s
INFO: Final Memory: 6M/295M
INFO: ------------------------------------------------------------------------