feat(module) use sys.stdlib_module_names to get stdlibs in Python >= 3.10#275
Merged
mkniewallner merged 5 commits intofpgmaas:mainfrom Jan 23, 2023
Conversation
Codecov Report
@@ Coverage Diff @@
## main #275 +/- ##
=======================================
- Coverage 95.7% 95.7% -0.1%
=======================================
Files 32 28 -4
Lines 915 907 -8
Branches 191 186 -5
=======================================
- Hits 876 868 -8
Misses 26 26
Partials 13 13
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
291564b to
ba319fb
Compare
mkniewallner
commented
Jan 22, 2023
|
|
||
| [tool.mypy] | ||
| files = ["deptry", "scripts", "tests"] | ||
| explicit_package_bases = true |
Collaborator
Author
There was a problem hiding this comment.
scripts directory doesn't have an __init__.py file, so this makes mypy understand that scripts is a Python module (https://mypy.readthedocs.io/en/stable/config_file.html#confval-explicit_package_bases).
fpgmaas
approved these changes
Jan 23, 2023
ba319fb to
c2873db
Compare
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR Checklist
docsis updatedDescription of changes
Python 3.10 introduced
sys.stdlib_module_namesto retrieve the list of modules that belong to the stdlib.This PR updates the stdlib modules retrieval in order to use this method on Python >= 3.10, while older versions would still depend on the generated list of modules that we get from the official documentation.
The main advantage of using
sys.stdlib_module_namesis that we will not need a new release ofdeptrythat generates stdlib modules for a new Python version whenever a new one is available.For instance, when using the latest alpha of Python 3.12 this would now work out of the box (while it would just crash without those changes):
Although we would not need to re-generate the stdlibs files for previous Python versions ever again, I still wanted to rework a bit the generation of stdlibs files by using an AST, which feels cleaner than custom string indentations, since we can them leverage
blackfor the formatting afterwards.It now also outputs the modules to a single location, to only have a single import and simplify the logic for Python < 3.10.