Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CI: remove Python 3.6 testing and add/fix Python 3.11 support #515

Merged
merged 6 commits into from
Dec 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,8 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ['3.6', '3.7', '3.8', '3.9', '3.10', 'pypy-3.9']
python-version: ['3.7', '3.8', '3.9', '3.10', '3.11', 'pypy-3.9']
include:
- python-version: '3.6'
pytest-args: --ignore=tests/__generated__/test_recursive_postponned.py
- python-version: '3.10'
pytest-args: --cov=apischema --cov-branch --cov-report=xml --cov-report=html
steps:
Expand Down
3 changes: 3 additions & 0 deletions apischema/json_schema/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ class JsonType(str, Enum):
def from_type(cls: Type) -> "JsonType":
return TYPE_TO_JSON_TYPE[cls]

def __str__(self) -> str:
return self.value


class JsonTypes(Dict[type, JsonType]):
def __missing__(self, key):
Expand Down
6 changes: 4 additions & 2 deletions apischema/typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,9 @@ def get_args(tp):
except ImportError:
pass

if sys.version_info >= (3, 7):
if sys.version_info >= (3, 11):
from typing import _collect_parameters as _collect_type_vars
elif sys.version_info >= (3, 7):
from typing import _collect_type_vars # type: ignore
else:
from typing import _type_vars as _collect_type_vars
Expand Down Expand Up @@ -274,7 +276,7 @@ def typing_origin(origin: Any) -> Any:

def is_type(tp: Any) -> bool:
"""isinstance is not enough because in py39: isinstance(list[int], type) == True"""
return isinstance(tp, type) and not get_args(tp)
return isinstance(tp, type) and not get_args(tp) and tp is not Any


def is_union(tp: Any) -> bool:
Expand Down
2 changes: 1 addition & 1 deletion examples/flattened.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class RootJsonSchema:
schema: str | UndefinedType = field(default=Undefined, metadata=alias("$schema"))
defs: list[JsonSchema] = field(default_factory=list, metadata=alias("$defs"))
# This field schema is flattened inside the owning one
json_schema: JsonSchema = field(default=JsonSchema(), metadata=flatten)
json_schema: JsonSchema = field(default_factory=JsonSchema, metadata=flatten)


data = {
Expand Down
6 changes: 3 additions & 3 deletions examples/ordering.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ def age(self) -> int:


user = User("Harry", "Potter", "London", date(1980, 7, 31))
dump = """{
dump = f"""{{
"trigram": "hpr",
"firstname": "Harry",
"lastname": "Potter",
"age": 41,
"age": {user.age},
"birthdate": "1980-07-31",
"address": "London"
}"""
}}"""
assert json.dumps(serialize(User, user), indent=4) == dump
5 changes: 4 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ ignore = E203, E302, E501, W503, E731, E741
[isort]
profile = black

[tool:pytest]
asyncio_mode = auto

[coverage:report]
;fail_under = 100
precision = 2
Expand All @@ -17,4 +20,4 @@ exclude_lines =
if TYPE_CHECKING
stop_signature_abuse()
if sys.version_info
def __getattr__(name):
def __getattr__(name):
2 changes: 1 addition & 1 deletion tests/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ docstring-parser==0.13
pydantic==1.9.0
pytest==7.0.1
pytest-cov==3.0.0
pytest-asyncio==0.16.0
pytest-asyncio==0.17.2
SQLAlchemy==1.4.32
typing-extensions==4.0.1
Cython==0.29.27