-
Notifications
You must be signed in to change notification settings - Fork 175
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
Bump mypy from 1.13.0 to 1.14.1 #1054
Conversation
Bumps [mypy](https://github.com/python/mypy) from 1.13.0 to 1.14.1. - [Changelog](https://github.com/python/mypy/blob/master/CHANGELOG.md) - [Commits](python/mypy@v1.13.0...v1.14.1) --- updated-dependencies: - dependency-name: mypy dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Test failures...
def __get__(self, instance: T, owner: type[Any]) -> R: | ||
@overload | ||
def __get__(self, instance: T, owner: type[Any]) -> R: ... | ||
|
||
@overload | ||
def __get__(self, instance: None, owner: type[Any]) -> Self: ... | ||
|
||
def __get__(self, instance: T | None, owner: type[Any]) -> R | Self: | ||
if instance is None: | ||
return self |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The problem here was that the new mypy version is smarter and correctly pointed out that return self
isn't actually returning an instance of R
, but instead a cached_property
instance directly.
This only happens when you try to access a cached_property on the class instead of an instance of the class, e.g.
from baseplate.lib import cached_property
class Bar:
@cached_property
def foo(self):
return "hello"
@property
def foo2(self):
return "hello"
bar = Bar()
print("bar.foo:", bar.foo)
print("bar.foo2:", bar.foo2)
print("Bar.foo:", Bar.foo)
print("Bar.foo2:", Bar.foo2)
prints:
$ poetry run python test.py
bar.foo: hello
bar.foo2: hello
Bar.foo: <baseplate.lib.cached_property object at 0x103278260>
Bar.foo2: <property object at 0x10313f920>
So we can see the the implementation appears to be correct since it behaves the same as the built-in @property
decorator, but the typing is wrong.
To fix this, we add overrides to explain to mypy that the return type is based on whether instance
is None
or not. If it is, we return Self
instead of R
.
Bumps mypy from 1.13.0 to 1.14.1.
Changelog
Sourced from mypy's changelog.
... (truncated)
Commits
251d12f
Remove +dev from version for release 1.14.1667e5f7
Revert "Remove redundant inheritances from Iterator in builtins" (#18324)67f673a
Fix enum truthiness for StrEnum (#18379)3755abb
Fix getargs argument passing (#18350)b9fa8ee
Update version to 1.14.1+dev for point release6f37859
Remove +dev from version for release 1.145a6a754
Minor updates to 1.14 changelog (#18310)9772d48
Update changelog for release 1.14 (#18301)92473c8
Warn about --follow-untyped-imports (#18249)e6ce8be
PEP 702 (@deprecated
): descriptors (#18090)Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting
@dependabot rebase
.Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR:
@dependabot rebase
will rebase this PR@dependabot recreate
will recreate this PR, overwriting any edits that have been made to it@dependabot merge
will merge this PR after your CI passes on it@dependabot squash and merge
will squash and merge this PR after your CI passes on it@dependabot cancel merge
will cancel a previously requested merge and block automerging@dependabot reopen
will reopen this PR if it is closed@dependabot close
will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually@dependabot show <dependency name> ignore conditions
will show all of the ignore conditions of the specified dependency@dependabot ignore this major version
will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)@dependabot ignore this minor version
will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)@dependabot ignore this dependency
will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)