-
-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Lenient handling of trivial Callable suffixes #15913
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
Changes from 4 commits
06c3625
cd06210
daf25c5
45309ba
89fcdb9
7165b6c
ffe43e3
71c4768
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 |
|---|---|---|
|
|
@@ -1778,6 +1778,7 @@ class CallableType(FunctionLike): | |
| # (this is used for error messages) | ||
| "imprecise_arg_kinds", | ||
| "unpack_kwargs", # Was an Unpack[...] with **kwargs used to define this callable? | ||
| "erased", # Is this callable created as an erased form of a more precise type? | ||
|
Collaborator
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 feels kind of ad hoc -- and there seems to overlap with
Member
Author
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. Yeah. This looks quite ad-hoc. The more think about it the more I think we should do this unconditionally. This will make the whole thing much simpler. |
||
| ) | ||
|
|
||
| def __init__( | ||
|
|
@@ -1803,6 +1804,7 @@ def __init__( | |
| from_concatenate: bool = False, | ||
| imprecise_arg_kinds: bool = False, | ||
| unpack_kwargs: bool = False, | ||
| erased: bool = False, | ||
| ) -> None: | ||
| super().__init__(line, column) | ||
| assert len(arg_types) == len(arg_kinds) == len(arg_names) | ||
|
|
@@ -1850,6 +1852,7 @@ def __init__( | |
| self.def_extras = {} | ||
| self.type_guard = type_guard | ||
| self.unpack_kwargs = unpack_kwargs | ||
| self.erased = erased | ||
|
|
||
| def copy_modified( | ||
| self: CT, | ||
|
|
@@ -1873,6 +1876,7 @@ def copy_modified( | |
| from_concatenate: Bogus[bool] = _dummy, | ||
| imprecise_arg_kinds: Bogus[bool] = _dummy, | ||
| unpack_kwargs: Bogus[bool] = _dummy, | ||
| erased: Bogus[bool] = _dummy, | ||
| ) -> CT: | ||
| modified = CallableType( | ||
| arg_types=arg_types if arg_types is not _dummy else self.arg_types, | ||
|
|
@@ -1903,6 +1907,7 @@ def copy_modified( | |
| else self.imprecise_arg_kinds | ||
| ), | ||
| unpack_kwargs=unpack_kwargs if unpack_kwargs is not _dummy else self.unpack_kwargs, | ||
| erased=erased if erased is not _dummy else self.erased, | ||
| ) | ||
| # Optimization: Only NewTypes are supported as subtypes since | ||
| # the class is effectively final, so we can use a cast safely. | ||
|
|
@@ -2220,6 +2225,7 @@ def serialize(self) -> JsonDict: | |
| "from_concatenate": self.from_concatenate, | ||
| "imprecise_arg_kinds": self.imprecise_arg_kinds, | ||
| "unpack_kwargs": self.unpack_kwargs, | ||
| "erased": self.erased, | ||
| } | ||
|
|
||
| @classmethod | ||
|
|
@@ -2244,6 +2250,7 @@ def deserialize(cls, data: JsonDict) -> CallableType: | |
| from_concatenate=data["from_concatenate"], | ||
| imprecise_arg_kinds=data["imprecise_arg_kinds"], | ||
| unpack_kwargs=data["unpack_kwargs"], | ||
| erased=data["erased"], | ||
| ) | ||
|
|
||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.