-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Dmypy 418 #18942
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
base: master
Are you sure you want to change the base?
Dmypy 418 #18942
Changes from all commits
7ecb077
b61c9ba
3ff8f89
6b08c08
3930148
4b1d260
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[mypy] | ||
check_untyped_defs = true |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -74,7 +74,6 @@ | |
TypeOfAny, | ||
TypeStrVisitor, | ||
TypeTranslator, | ||
TypeVarType, | ||
UninhabitedType, | ||
UnionType, | ||
get_proper_type, | ||
|
@@ -653,7 +652,7 @@ def extract_from_decorator(self, node: Decorator) -> FuncDef | None: | |
for ct in typ.items: | ||
if not ( | ||
len(ct.arg_types) == 1 | ||
and isinstance(ct.arg_types[0], TypeVarType) | ||
# and isinstance(ct.arg_types[0], TypeVarType) | ||
and ct.arg_types[0] == ct.ret_type | ||
): | ||
return None | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is looks like a special case for this decorator: def f(x: T) -> T:
return x you should add a special case in addition to this. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Well, technically this line is limiting to that special case. And this will even fix the linked issue, two callables of that shape will compare equal AFAIC. But this also makes the following (completely wrong) deco generate a signature: def deco(fn: str) -> str: ...
@deco
def foo():
print() So I agree there should be one more special case, not just blanket "one-arg function returning its arg unchanged". |
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
from typing import Callable, TypeVar | ||
from typing_extensions import ParamSpec | ||
|
||
R = TypeVar("R") | ||
P = ParamSpec("P") | ||
|
||
|
||
def dec(f: Callable[P, R]) -> Callable[P, R]: | ||
return f | ||
|
||
|
||
@dec | ||
def f() -> None: | ||
print("hello world") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is talking about importing
typing
and this isn't the convention.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, the convention is "never alias-import stdlib modules unless strictly necessary". Please revert this doc change along with all imports garbled in other files.