Repository navigation
Exclude missing type variable defaults from precision reports - #22429
Closed
mengqing88 wants to merge 2 commits into
Closed
mengqing88 wants to merge 2 commits into
mengqing88 wants to merge 2 commits into
Conversation
This comment has been minimized.
This comment has been minimized.
Contributor
|
Diff from mypy_primer, showing the effect of this PR on open source code: pywin32 (https://github.com/mhammond/pywin32)
./pythonwin/pywin/test/_dbgscript.py: error: INTERNAL ERROR -- Please try using mypy master on GitHub:
- version: 2.5.0+dev.b83696ea8099ef3772a5a2bc2c49f2b05340c37a
+ version: 2.5.0+dev.a57c949e0039fc6d08c8ef5cf3cce61e1f77a361
|
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.
Precision reports classify fully annotated generic functions as imprecise because a type variable without a default stores
AnyType(TypeOfAny.from_omitted_generics)as its internal default. For example, a signature-preservingCallable[P, T]decorator reports imprecision onP.args/P.kwargseven though noAnyis present in the source and the wrapped return type is preserved. The same sentinel also inflatestypes-of-anys.txt: the new generic-only fixture currently reports 24 omitted-generic Anys.Exclude the missing-default sentinel when traversing
TypeVar,ParamSpec, andTypeVarTuplefor statistics. Apply the same traversal to precision classification and Any collection so their results remain consistent. Actual defaults, upper bounds, constraints, and ParamSpec prefixes are still traversed, and real omitted generic arguments are still reported. The change is confined to statistics; it does not change type checking, inference, or the treatment of calls acceptingAny.Validation on Python 3.11 / Windows:
python -m pytest -n0 -q mypy/test/testcheck.py mypy/test/testcmdline.py mypy/test/testreports.py -k 'reports.test or CoberturaReportSuite').python -m mypy --config-file mypy_self_check.ini -p mypy).git diff --checkpassed.json.dumpsretains its existing Any marker.Python 3.10 CI follow-up: the generic-only report fixture now imports
TypeVarTupleandUnpackfromtyping_extensions. The original failure was reproduced on Python 3.10 before this change; all 23 command-line report cases pass on both Python 3.10 and Python 3.11 after it.AI assistance: Codex assisted with the investigation, implementation, and test preparation.