DEP: adjust requirements for extra dependency on typing-extensions#15686
Conversation
|
Thank you for your contribution to Astropy! 🌌 This checklist is meant to remind the package maintainers who will review this pull request of some common things to look for.
|
|
I guess that the adjustment in minimal required version is technically a bug fix, so I'd suggest to backport this. |
| if TYPE_CHECKING: | ||
| import sys | ||
| from typing import Any, Callable | ||
|
|
||
| from typing_extensions import Self | ||
|
|
||
| from astropy.units import UnitBase | ||
|
|
||
| if sys.version_info >= (3, 11): | ||
| from typing import Self | ||
| else: | ||
| from typing_extensions import Self |
There was a problem hiding this comment.
This if TYPE_CHECKING: block was added in #15354. An early version of that pull request did include explicitly version dependent code, but during the review @nstarman pointed out that Ruff (specifically UP035) knows enough about typing and typing_extensions that it can automatically change the import when support for Python 3.10 is dropped. The change proposed here is not necessary.
There was a problem hiding this comment.
Ruff (specifically UP035) knows enough about typing and typing_extensions that it can automatically change the import when support for Python 3.10 is dropped.
good to know, but that's not why I added it here; my reasoning is that, I can't make typing-extensions a py310- only extra dependency without handling the py311+ case explicitly in code.
If you guys still prefer to keep the current style that's fine with me, and in that case, please feel free to close !
There was a problem hiding this comment.
Then it might be a good idea to have explicitly version-dependent code here after all. Note that Ruff rule UP036 recognizes obsolete sys.version_info comparisons, so there's no reason we should use astropy.utils.compat.PYTHON_LT_3_11 here.
There was a problem hiding this comment.
I still think it's best to not version check on typing_extension imports. The package does it internally and its MO is to make using typing features seamless. Later version-dependent code doesn't care where Self is from so long as it's there. And with typing_extensions it always will be.
There was a problem hiding this comment.
Is this conversation resolved or not? Is this PR good to merge? @eerovaher ?
| ----- | ||
| With Python 3.9+ or :mod:`typing_extensions`, |Quantity| types are also | ||
| static-type compatible. | ||
| |Quantity| types are also static-type compatible. |
There was a problem hiding this comment.
In the pull request @nstarman opened to drop support for Python 3.9 he also found some code and documentation that should or could have been updated when support for Python 3.8 was dropped. That pull request has not been merged yet. Perhaps it would be a good idea to open a separate pull request for removing the obsolete mentions of Python 3.9 like this.
There was a problem hiding this comment.
The problem with #15603 is that it seems to be stuck because the reference images for image comparison tests need to be regenerated. It would be better to split off things from there in new pull requests instead of adding more things to it that would then get stuck too.
There was a problem hiding this comment.
Agreed. Anything that can be paired off is good. Feel free to 🍒pick commits.
There was a problem hiding this comment.
Ok, I'll move it to a separate branch, and will open a PR in a few days with maybe more of the same !
| "fsspec[http]>=2023.4.0", | ||
| "s3fs>=2023.4.0", | ||
| "pre-commit", | ||
| "typing_extensions>=4.0.0 ; python_version < '3.11'", |
There was a problem hiding this comment.
It is good to try to keep track of why typing_extensions is needed, but it is also important to record the reason in commit messages.
There was a problem hiding this comment.
Thanks @neutrinoceros! Looks good as is, but I have a small suggestion. Also @eerovaher's comment on comments is good, lest we forget why typing_extensions is version-pinned
|
Do we actually need |
it's currently only included as an extra dependency (part of the |
0cd8d5c to
2d1e924
Compare
|
@eerovaher @nstarman I just removed the adjacent-but-not-strictly-related part of the patch and amended the commit message with more details. |
|
If we don't list |
|
Then I'll leave it to @nstarman to decide what to do here since he previously approved, but again, no harm done in closing this PR if we don't collectively think it's needed :) |
|
I'm not suggesting to close this pull request without merging, I'm suggesting remove |
|
I think if someone installs |
|
Fine by me @nstarman. I'm also happy to open another PR to implement your proposed |
Much appreciated! |
|
done in #15689 |
|
Merge this first or what's the order? |
|
@nstarman any order is fine, I'll just need to rebase whatever comes in second |
|
What is this pull request supposed to do when #15689 is merged? |
|
Add the info. 2 small PRs. Could combine, but it's fine as is, reflecting our discussions. |
2d1e924 to
d703f40
Compare
|
rebased and updated. Now it should be clear what it does on top of #15689 , and it's good to go ! |
|
I don't think the version check is necessary for preventing unwanted installations of |
I respectfully disagree here, but I won't insist. Again, I'm fine with this PR being closed if it's controversial. |
|
I believe the only remaining failure is due to #15692, which I think can be resolved separately, so I'll start working on that now. |
|
Will this fix #15819 ? If so, can we wrap this up for merge? Thanks! |
|
Actually needs a rebase, and then I can slap "Extra CI" on this, to be sure. |
I don't think so, but I'll rebase now anyway ! |
At the moment, typing-extensions is only ever used to replace `typing.Self`, which is included in the standard library from Python 3.11 on. The backport symbol, `typing_extensions.Self`, requires version 4.0 (or newer).
d703f40 to
169f461
Compare
|
Hmm link check is green here. 🤷 |
|
My personal preference would be to just have |
Description
@hamogu @eerovaher
While reviewing #15685, I noticed that requirements on
typing_extensionsneeded slight adjustements:Selfsymbol, which was added in version 4.0.0typing.Self) in Python 3.11 and newer, so I made this requirement py310- onlyI also found a note in a doctoring that doesn't seem relevant now that support for Python 3.8 was dropped.