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

update AnyClassMethod for change in python/typeshed#9771 #5505

Merged
merged 4 commits into from
Apr 24, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions changes/5505-ITProKyle.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
update `AnyClassMethod` for changes in [python/typeshed#9771](https://github.com/python/typeshed/issues/9771)
3 changes: 2 additions & 1 deletion pydantic/typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,8 @@ def is_union(tp: Optional[Type[Any]]) -> bool:
MappingIntStrAny = Mapping[IntStr, Any]
CallableGenerator = Generator[AnyCallable, None, None]
ReprArgs = Sequence[Tuple[Optional[str], Any]]
AnyClassMethod = classmethod[Any]
# classmethod[TargetType, CallableParamSpecType, CallableReturnType]
AnyClassMethod = classmethod[Any, Any, Any]
adriangb marked this conversation as resolved.
Show resolved Hide resolved
Copy link
Contributor

@dmontagu dmontagu Apr 18, 2023

Choose a reason for hiding this comment

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

Suggested change
AnyClassMethod = classmethod[Any, Any, Any]
MYPY = False
if not MYPY:
AnyClassMethod = classmethod[Any, Any, Any]
else:
AnyClassMethod = classmethod[Any]

I would suggest reverting the change to the mypy version (i.e., change it back to 0.971 in requirements-linting.txt) and making this change instead, which I think should result in the update to the definition used by pyright but not mypy.

I think this should keep everything else behaving the same (so we don't need to worry about breaking existing mypy functionality), but please confirm that this change would work for you with pyright.

As far as I'm currently aware it's not our intention to support mypy v1.2.0 with pydantic v1, given the various breaking changes (it will be supported in pydantic v2 though), so I wouldn't worry about updating the requirements-linting.txt.

Copy link
Author

@ITProKyle ITProKyle Apr 18, 2023

Choose a reason for hiding this comment

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

It didn't work on the pright side as provided but it did work with the condition swapped. It also worked locally with mypy==0.971.


__all__ = (
'AnyCallable',
Expand Down
2 changes: 1 addition & 1 deletion tests/requirements-linting.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ flake8-quotes==3.3.1
hypothesis==6.54.4
isort==5.10.1
pyupgrade==2.37.3
mypy==0.971
mypy==1.2.0
samuelcolvin marked this conversation as resolved.
Show resolved Hide resolved
pre-commit==2.20.0
pycodestyle==2.9.1
pyflakes==2.5.0
Expand Down