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

Add import compat layer to __init__ #24

Merged
merged 11 commits into from
Oct 6, 2024
Merged

Add import compat layer to __init__ #24

merged 11 commits into from
Oct 6, 2024

Conversation

bdraco
Copy link
Member

@bdraco bdraco commented Oct 6, 2024

What do these changes do?

Add import compat layer to init so the public API can continue to be imported at top level

Are there changes in behavior for the user?

Restores the ability to import from top-level

Related issue number

#18

@psf-chronographer psf-chronographer bot added the bot:chronographer:provided There is a change note present in this PR label Oct 6, 2024
tests/test_init.py Dismissed Show dismissed Hide dismissed
Copy link

codecov bot commented Oct 6, 2024

Codecov Report

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

Project coverage is 86.56%. Comparing base (b762a3c) to head (8f21e75).
Report is 2 commits behind head on master.

Files with missing lines Patch % Lines
src/propcache/__init__.py 85.71% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master      #24      +/-   ##
==========================================
+ Coverage   85.98%   86.56%   +0.57%     
==========================================
  Files          20       21       +1     
  Lines         678      722      +44     
  Branches       50       57       +7     
==========================================
+ Hits          583      625      +42     
- Misses         68       69       +1     
- Partials       27       28       +1     
Flag Coverage Δ
CI-GHA 86.28% <94.44%> (+0.59%) ⬆️
MyPy 68.67% <66.66%> (-0.25%) ⬇️
OS-Linux 98.87% <100.00%> (+0.13%) ⬆️
OS-Windows 93.77% <100.00%> (+0.92%) ⬆️
OS-macOS 96.99% <100.00%> (+0.36%) ⬆️
Py-3.10.11 96.61% <100.00%> (+0.41%) ⬆️
Py-3.10.15 98.12% <100.00%> (+0.23%) ⬆️
Py-3.11.10 98.12% <100.00%> (+0.23%) ⬆️
Py-3.11.9 96.61% <100.00%> (+0.41%) ⬆️
Py-3.12.6 97.71% <100.00%> (+0.23%) ⬆️
Py-3.13.0-rc.3 97.71% <100.00%> (+0.23%) ⬆️
Py-3.8.10 96.61% <100.00%> (+0.41%) ⬆️
Py-3.8.18 98.12% <100.00%> (+0.23%) ⬆️
Py-3.9.13 96.61% <100.00%> (+0.41%) ⬆️
Py-3.9.20 98.12% <100.00%> (+0.23%) ⬆️
Py-pypy7.3.11 95.11% <100.00%> (+0.72%) ⬆️
Py-pypy7.3.16 95.11% <100.00%> (+0.72%) ⬆️
Py-pypy7.3.17 95.11% <100.00%> (+0.72%) ⬆️
VM-macos-latest 96.99% <100.00%> (+0.36%) ⬆️
VM-ubuntu-latest 98.87% <100.00%> (+0.13%) ⬆️
VM-windows-latest 93.77% <100.00%> (+0.92%) ⬆️
pytest 98.69% <100.00%> (+0.13%) ⬆️

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.

tests/test_init.py Outdated Show resolved Hide resolved
tests/test_init.py Outdated Show resolved Hide resolved
src/propcache/__init__.py Outdated Show resolved Hide resolved
CHANGES/24.feature.rst Outdated Show resolved Hide resolved
@bdraco bdraco marked this pull request as ready for review October 6, 2024 19:02
@bdraco bdraco merged commit a68b078 into master Oct 6, 2024
49 checks passed
@bdraco bdraco deleted the api_import_facade branch October 6, 2024 19:36
@@ -38,6 +38,6 @@ coverage:
typing:
flags:
- MyPy
target: 70% # 100%
target: 68.5% # 100%
Copy link
Member

Choose a reason for hiding this comment

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

@bdraco why did you lower this? The currently reported number is 87.50% per https://app.codecov.io/gh/aio-libs/propcache?flags%5B0%5D=MyPy. Honestly, I'd prefer MyPy coverage to be fixed rather than discarded. Looking into https://app.codecov.io/gh/aio-libs/propcache/blob/master/tests%2Ftest_init.py?flags%5B0%5D=MyPy, most of it is not that hard to address.

Copy link
Member Author

@bdraco bdraco Oct 6, 2024

Choose a reason for hiding this comment

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

I kept getting different results on each run so I under the impression it was an order of delivery problem to Codecov.

Do you have a suggestion on how to type propcache_module?

Copy link
Member Author

Choose a reason for hiding this comment

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

I guess ModuleType will work here

def imported_module(self) -> ModuleType:

Copy link
Member Author

@bdraco bdraco Oct 6, 2024

Choose a reason for hiding this comment

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

Doors closing, switching to mobile, will do more if wifi works in flight

Copy link
Member Author

Choose a reason for hiding this comment

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

#33

Copy link
Member Author

Choose a reason for hiding this comment

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

#34

Copy link
Member Author

Choose a reason for hiding this comment

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

Any idea why its missing on these lines?

Screenshot 2024-10-06 at 6 16 32 PM

Copy link
Member

Choose a reason for hiding this comment

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

@bdraco try using the from .api import cached_property as cached_property syntax in __init__.py. I've been trying to figure out similar things recently, and the experience needs improving: https://discuss.python.org/t/is-there-any-tool-that-can-report-type-coverage-of-a-project/34962/4.
It might be a rule we disable, but it still influences the coverage precision metric. So it wouldn't show up in the console output, but type coverage would be incomplete. I also saw mentions of when something in the type resolves to Any, that would make the line imprecise/uncovered. And MyPy does not have a # pragma: no cover to make it go away.

bdraco added a commit that referenced this pull request Oct 6, 2024
We do not want to support wildcard imports, make sure they do not work

#24 (comment)
bdraco added a commit that referenced this pull request Oct 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bot:chronographer:provided There is a change note present in this PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants