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

Publically re-export __version__ #3186

Merged
merged 3 commits into from
Jan 21, 2025
Merged

Conversation

CoolCat467
Copy link
Member

In this pull request, we publicly re-export __version__. This came up when working on python-trio/trio-websocket#193, where some of the unit test code looks at Trio's version for version-dependent things and mypy is not happy about accessing __version__.

Copy link
Contributor

@A5rocks A5rocks left a comment

Choose a reason for hiding this comment

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

IMO we should encourage importlib.metadata (eg in the newsfragment). But this is fine as a bugfix to something we thought worked.

Copy link

codecov bot commented Jan 14, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00000%. Comparing base (5ca9662) to head (379d9ce).
Report is 4 commits behind head on main.

Additional details and impacted files
@@               Coverage Diff               @@
##                 main        #3186   +/-   ##
===============================================
  Coverage   100.00000%   100.00000%           
===============================================
  Files             124          124           
  Lines           18460        18460           
  Branches         1216         1216           
===============================================
  Hits            18460        18460           
Files with missing lines Coverage Δ
src/trio/__init__.py 100.00000% <100.00000%> (ø)

@jakkdl
Copy link
Member

jakkdl commented Jan 15, 2025

IMO we should encourage importlib.metadata (eg in the newsfragment). But this is fine as a bugfix to something we thought worked.

well, it does work currently so this isn't really a bugfix per se. By publicly re-exporting it we're making it part of the official API, so I think perhaps this shouldn't be done at all?

@A5rocks
Copy link
Contributor

A5rocks commented Jan 18, 2025

IMO we should encourage importlib.metadata (eg in the newsfragment). But this is fine as a bugfix to something we thought worked.

well, it does work currently so this isn't really a bugfix per se. By publicly re-exporting it we're making it part of the official API, so I think perhaps this shouldn't be done at all?

The comment implies we thought it would work, and that it does in pyright. Also, is this PR even necessary?:

(.venv) PS C:\Users\A5rocks\Documents\Temp\a> mypy -c "import trio; reveal_type(trio.__version__)"
<string>:1: note: Revealed type is "builtins.str"
Success: no issues found in 1 source file

@CoolCat467
Copy link
Member Author

Try with --strict or at the very least --no-implicit-reexport

@A5rocks A5rocks added this pull request to the merge queue Jan 21, 2025
Merged via the queue into python-trio:main with commit 1c6a6a8 Jan 21, 2025
39 checks passed
@CoolCat467 CoolCat467 deleted the export-version branch January 21, 2025 06:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants