Skip to content

Change type from Any to object for under_cached_property.__get__ - #50

Merged
webknjaz merged 1 commit into
masterfrom
type_object
Oct 8, 2024
Merged

webknjaz merged 1 commit into
masterfrom
type_object

Conversation

@bdraco

@bdraco bdraco commented Oct 7, 2024 •

Copy link
Copy Markdown
Member

If the implementation is type safe with anything, then it should be updated to object. I've had discussions in typeshed before, and the consensus is that typeshed should use object in such circumstances (otherwise, it triggers Any warnings in mypy if all the any warnings are enabled, anytime a user uses that function).

Originally posted by @Dreamsorcerer in #38 (comment)

@bdraco bdraco added the bot:chronographer:skip This PR does not need to include a change note label Oct 7, 2024

@overload
def __get__(self, inst: None, owner: Optional[Type[Any]] = None) -> Self: ...
def __get__(self, inst: None, owner: Optional[Type[object]] = None) -> Self: ...

Check notice

Code scanning / CodeQL

Statement has no effect

This statement has no effect.

@overload
def __get__(self, inst: _TSelf[_T], owner: Optional[Type[Any]] = None) -> _T: ...
def __get__(self, inst: _TSelf[_T], owner: Optional[Type[object]] = None) -> _T: ...

Check notice

Code scanning / CodeQL

Statement has no effect

This statement has no effect.
@bdraco

bdraco commented Oct 7, 2024 •

Copy link
Copy Markdown
Member Author

Seems ok downstream in yarl

@bdraco

bdraco commented Oct 7, 2024

Copy link
Copy Markdown
Member Author

Seems ok in aiohttp

@codecov

codecov Bot commented Oct 7, 2024 •

Copy link
Copy Markdown

Codecov Report

Attention: Patch coverage is 33.33333% with 2 lines in your changes missing coverage. Please review.

Project coverage is 88.24%. Comparing base (cc02c1f) to head (883fdb7).
Report is 42 commits behind head on master.

Files with missing lines Patch % Lines
src/propcache/_helpers_py.py 33.33% 0 Missing and 2 partials ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##           master      #50   +/-   ##
=======================================
  Coverage   88.24%   88.24%           
=======================================
  Files          17       17           
  Lines         689      689           
  Branches       98       98           
=======================================
  Hits          608      608           
  Misses         63       63           
  Partials       18       18           
Flag Coverage Δ
CI-GHA 88.24% <33.33%> (ø)
MyPy 77.84% <33.33%> (ø)
OS-Linux 98.38% <ø> (ø)
OS-Windows 93.65% <ø> (ø)
OS-macOS 94.17% <ø> (ø)
Py-3.10.11 92.88% <ø> (ø)
Py-3.10.15 95.46% <ø> (ø)
Py-3.11.10 95.46% <ø> (ø)
Py-3.11.9 92.88% <ø> (ø)
Py-3.12.6 95.46% <ø> (ø)
Py-3.12.7 ?
Py-3.13.0-rc.3 95.46% <ø> (ø)
Py-3.8.10 93.18% <ø> (ø)
Py-3.8.18 95.77% <ø> (ø)
Py-3.9.13 92.85% <ø> (ø)
Py-3.9.20 95.45% <ø> (ø)
Py-pypy7.3.11 95.50% <ø> (ø)
Py-pypy7.3.16 95.13% <ø> (ø)
Py-pypy7.3.17 95.14% <ø> (ø)
VM-macos-latest 94.17% <ø> (ø)
VM-ubuntu-latest 98.38% <ø> (ø)
VM-windows-latest 93.65% <ø> (ø)
pytest 98.38% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@bdraco
bdraco marked this pull request as ready for review October 7, 2024 21:31
@Dreamsorcerer

Copy link
Copy Markdown
Member

For calling code, this change could only remove errors, not introduce them (i.e. if using --warn-any-expr).

@bdraco

bdraco commented Oct 7, 2024 •

Copy link
Copy Markdown
Member Author

Before
MyPy flags
All Flags

After
MyPy flags
All Flags

@bdraco

bdraco commented Oct 7, 2024

Copy link
Copy Markdown
Member Author

Super confusing that Coverage not affected when comparing cc02c1f...883fdb7 in the CI checks and ..

Attention: Patch coverage is 33.33333% with 2 lines in your changes missing coverage. Please review.
#50 (comment)

@bdraco

bdraco commented Oct 7, 2024

Copy link
Copy Markdown
Member Author

https://mypy.readthedocs.io/en/latest/dynamic_typing.html#any-vs-object

If you’re not sure whether you need to use object or Any, use object – only switch to using Any if you get a type checker complaint.

I'd say we didn't get any complaints so that seems to be the prescribed way to go.

@bdraco

bdraco commented Oct 7, 2024

Copy link
Copy Markdown
Member Author

Too tired and jet lagged to revalidate so I'll leave this for someone else to ✅ and merge or I'll take a look again when I've had some sleep.

Comment thread src/propcache/_helpers_py.py Resolved
Comment thread src/propcache/_helpers_py.py Resolved
Comment thread src/propcache/_helpers_py.py Resolved
@bdraco

bdraco commented Oct 8, 2024

Copy link
Copy Markdown
Member Author

I think this is good to merge as-is, but I wasn't 100% on all the discussions above so I'll leave it until they are resolved above.

@webknjaz

webknjaz commented Oct 8, 2024

Copy link
Copy Markdown
Member

I think it's okay to merge. This is probably best we can do right now.

@webknjaz
webknjaz enabled auto-merge (squash) October 8, 2024 11:23
@webknjaz
webknjaz merged commit 6096a8a into master Oct 8, 2024
@webknjaz
webknjaz deleted the type_object branch October 8, 2024 12:24
@Dreamsorcerer Dreamsorcerer mentioned this pull request Oct 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bot:chronographer:skip This PR does not need to include a change note

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants