Skip to content

Commit

Permalink
chore: styling and linting fixes (jpmorganchase#64)
Browse files Browse the repository at this point in the history
  • Loading branch information
dada-engineer committed Mar 18, 2024
1 parent 5b4a40e commit b841268
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
[flake8]
# Flake 8 linting configuration, not supported in pyproject.toml

ignore = E203,W503
ignore = E203,W503,E701
max-line-length = 120
exclude =
.svn,
Expand Down
5 changes: 3 additions & 2 deletions src/py_avro_schema/_schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -619,8 +619,9 @@ def handles_type(cls, py_type: Type) -> bool:

# Support for `X | Y` syntax available in Python 3.10+
# equivalent to `typing.Union[X, Y]`
if getattr(types, "UnionType", None):
return origin == Union or origin == types.UnionType # noqa: E721
union_type = getattr(types, "UnionType", None)
if union_type:
return origin == Union or origin == union_type
return origin == Union

def __init__(self, py_type: Type[Union[Any]], namespace: Optional[str] = None, options: Option = Option(0)):
Expand Down
9 changes: 3 additions & 6 deletions tests/test_primitives.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ def test_str_annotated():


def test_str_subclass():
class PyType(str):
...
class PyType(str): ...

expected = {
"type": "string",
Expand All @@ -55,8 +54,7 @@ class PyType(str):


def test_str_subclass_namespaced():
class PyType(str):
...
class PyType(str): ...

expected = {
"type": "string",
Expand All @@ -68,8 +66,7 @@ class PyType(str):
def test_str_subclass_other_classes():
import packaging.version

class PyType(packaging.version.Version, str):
...
class PyType(packaging.version.Version, str): ...

expected = {
"type": "string",
Expand Down

0 comments on commit b841268

Please sign in to comment.