Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Back out get_origin() parameter type #13999

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

Merged
merged 9 commits into from
May 11, 2025

Conversation

JelleZijlstra
Copy link
Member

From #13985

This comment has been minimized.

@JelleZijlstra
Copy link
Member Author

Somehow this doesn't change the mypy-primer hits back, but they did change in #13998. Not sure if mypy has nondeterministic behavior or we hit a bug in mypy-primer.

This comment has been minimized.

@hauntsaninja
Copy link
Collaborator

hauntsaninja commented May 11, 2025

I do see primer if I revert the whole PR: #14009

Not sure what was up with #13998 . It's possible that mypy is non-deterministic (I know of one case where it is), or mypy_primer has a bug, or github did something weird

@JelleZijlstra
Copy link
Member Author

I wonder if the new typing -> _typeshed dependency confused some import graph cycle. Let me try moving that alias to typing.

This comment has been minimized.

@srittau
Copy link
Collaborator

srittau commented May 11, 2025

We could add _AnnotationForm to typing (with a comment linking to _typeshed). I think this would be good for documentation. Alternatively, we could just use typing._AnnotationForm everywhere.

@JelleZijlstra JelleZijlstra marked this pull request as draft May 11, 2025 15:21

This comment has been minimized.

srittau
srittau previously approved these changes May 11, 2025
@JelleZijlstra
Copy link
Member Author

No effect from mypy primer so this version isn't right. Creating a type alias in typing.pyi is tricky because type checkers might not know yet that TypeAlias exists when they reach the alias.

@srittau srittau dismissed their stale review May 11, 2025 16:26

This is confusing ...

@srittau
Copy link
Collaborator

srittau commented May 11, 2025

No effect from mypy primer so this version isn't right. Creating a type alias in typing.pyi is tricky because type checkers might not know yet that TypeAlias exists when they reach the alias.

Ok, in that case we should go with your initial idea of using Any and just add an # AnnotationForm comment to the signatures in question.

Copy link
Contributor

Diff from mypy_primer, showing the effect of this PR on open source code:

ibis (https://github.com/ibis-project/ibis)
- ibis/expr/operations/udf.py:143: error: Dict entry 0 has incompatible type "str": "Int64"; expected "str": "Argument"  [dict-item]

artigraph (https://github.com/artigraph/artigraph)
- src/arti/types/python.py:145: error: Non-overlapping identity check (left operand type: "ParamSpec", right operand type: "<typing special form>")  [comparison-overlap]
- src/arti/types/python.py:167: error: Non-overlapping identity check (left operand type: "ParamSpec", right operand type: "<typing special form>")  [comparison-overlap]

hydra-zen (https://github.com/mit-ll-responsible-ai/hydra-zen)
- src/hydra_zen/_utils/coerce.py:111: error: Need type annotation for "list_caster_by_pos" (hint: "list_caster_by_pos: dict[<type>, <type>] = ...")  [var-annotated]
- src/hydra_zen/_utils/coerce.py:112: error: Need type annotation for "list_caster_by_name" (hint: "list_caster_by_name: dict[<type>, <type>] = ...")  [var-annotated]
- src/hydra_zen/_utils/coerce.py:149: error: Incompatible types in assignment (expression has type "type", variable has type "ParamSpec")  [assignment]

koda-validate (https://github.com/keithasaurus/koda-validate)
- koda_validate/typehints.py:135: error: Non-overlapping identity check (left operand type: "ParamSpec", right operand type: "type[Just[A]]")  [comparison-overlap]

@JelleZijlstra JelleZijlstra marked this pull request as ready for review May 11, 2025 22:22
@JelleZijlstra JelleZijlstra requested a review from srittau May 11, 2025 22:22
@JelleZijlstra JelleZijlstra merged commit 30b7b67 into python:main May 11, 2025
64 checks passed
@JelleZijlstra JelleZijlstra deleted the back-out-origin branch May 11, 2025 22:58
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