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

feature[next]: support for Python 3.11 #1407

Closed
wants to merge 11 commits into from
Closed

Conversation

havogt
Copy link
Contributor

@havogt havogt commented Jan 4, 2024

Fixes hidden bugs in datamodels and extended_typing to support Python 3.11.

Actual bug fixes:

  • Previous fix to support typing.Any implementation as a class (python/cpython@5a4973e) didn't work in 3.11.
  • Partially concretization of generic datamodels replacing typevars was broken.
  • Partially concretization of generic datamodels leaving some parameters as typevars was broken.

Other changes:

  • Add python 3.11 as supported version.
  • Remove dead code in comments.
  • Fix some imports style to comply with our coding guidelines.

namespace = {
"__annotations__": new_annotations,
"__module__": module if module else datamodel_cls.__module__,
"__bound_type_params__": bound_type_params, # TODO(havogt) is this useful information?
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure if it's useful to store this, it allows to do the check above

@@ -971,6 +971,14 @@ def __pretty__(
return __pretty__


def _is_concrete_data_model(
cls: Type, type_args: Tuple[Type]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if cls: Type, we need to do more checks inside, try again Type[GenericDataModelT]

@kotsaloscv kotsaloscv added dependencies Pull requests that update a dependency file and removed dependencies Pull requests that update a dependency file labels Jan 4, 2024
@@ -358,6 +358,8 @@ def make_is_instance_of(name: str, type_: type) -> FixedTypeValidator:
"""Create an ``FixedTypeValidator`` validator for a specific type."""

def _is_instance_of(value: Any, **kwargs: Any) -> None:
if type_ is Any:
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

possibly tests are wrong

Copy link
Contributor

@egparedes egparedes Jan 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The actual reason for this was actually a bug in a previous fix for dealing with the implementation of typing.Any as a type in modern python & typing_extensions versions. I removed this fix and applied the proper bug fix in extended_typing.

@egparedes egparedes self-requested a review January 19, 2024 10:14
@egparedes
Copy link
Contributor

@havogt could you take a look to my changes? Should we open a new PR for you being able to review it?

@havogt
Copy link
Contributor Author

havogt commented Jan 19, 2024

Please open a new PR, I don't always want to get github credit for your work. ;)

@egparedes
Copy link
Contributor

egparedes commented Jan 19, 2024

Closing in favor of #1418

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants