[ty] add special case diagnostic for numbers module#22931
[ty] add special case diagnostic for numbers module#22931AlexWaygood merged 7 commits intoastral-sh:mainfrom
Conversation
Signed-off-by: Bhuminjay <bhuminjaysoni@gmail.com>
Signed-off-by: Bhuminjay <bhuminjaysoni@gmail.com>
Typing conformance resultsNo changes detected ✅ |
|
There was a problem hiding this comment.
I think it would be more robust to add a KnownModule::Numbers variant and do something like target_instance.class(db).file(db).module(db).is_known(db, KnownModule::Numbers) to check whether the class comes from the numbers module
There was a problem hiding this comment.
yeah that would be much more better.
There was a problem hiding this comment.
also do we want this special case in case of invalid argument case in this case ?
from numbers import Number
def f(x: Number): ...
f(1)
as currently for thi case this would not emit the special case info.
There was a problem hiding this comment.
that would also be nice, yes. That could be a followup
Signed-off-by: Bhuminjay <bhuminjaysoni@gmail.com>
Signed-off-by: Bhuminjay <bhuminjaysoni@gmail.com>
Signed-off-by: Bhuminjay <bhuminjaysoni@gmail.com>
Signed-off-by: Bhuminjay <bhuminjaysoni@gmail.com>
|
since the logic will be pretty much same for invalid argument case , should I create a follow up PR ? |
yes, go for it! Ideally we'll pull out the subdiagnostic logic into a helper function that can be called from both places |
oh sure, will do that. |
* main: (76 commits) [ty] Improve the check for `NewType`s with generic bases (#22961) [ty] Ban legacy `TypeVar` bounds or constraints from containing type variables (#22949) Bump the typing conformance suite pin (#22960) [ty] Emit an error if a TypeVarTuple is used to subscript `Generic` or `Protocol` without being unpacked (#22952) [ty] Reduce false positives when subscripting classes generic over `TypeVarTuple`s (#22950) [ty] Detect invalid attempts to subclass `Protocol[]` and `Generic[]` simultaneously (#22948) Fix suppression indentation matching (#22903) Remove hidden `--output-format` warning (#22944) [ty] Validate signatures of dataclass `__post_init__` methods (#22730) [ty] extend special-cased `numbers` diagnostic to `invalid-argument-type` errors (#22938) [ty] Avoid false positive for `not-iterable` with no-positive intersection types (#22089) [ty] Preserve pure negation types in descriptor protocol (#22907) [ty] add special-case diagnostic for `numbers` module (#22931) [ty] Move the location of more `invalid-overload` diagnostics (#22933) [ty] Fix unary and comparison operators for TypeVars with union bounds (#22925) [ty] Rule Selection: ignore/warn/select all rules (unless subsequently overriden) (#22832) [ty] Fix TypedDict construction from existing TypedDict values (#22904) [ty] fix bug in string annotations and clean up diagnostics (#22913) [ty] Improve support for goto-type, goto-declaration, hover, and highlighting of string annotations (#22878) [ty] Rename old typing imports to new on `unresolved-reference`. (#22827) ...
Summary
This PR fixes astral-sh/ty#2563
Test Plan
added snapshot & mdtest.