Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork33.7k
gh-116126: Implement PEP 696#116129
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
gh-116126: Implement PEP 696#116129
Changes from1 commit
e7ca092828679ed3b472b6e467eefa4858049b077b5cfd5e201b32707a69204a2650080c282978aa5b27bdd01bb2c28b9ab0d467fd7e91e235226b42e079eee0370527b15f1111bd102c54aeed71a348b900cd40c13420b8a08c62613159f4e0435e7d54ace12581d82b5a102a2c48c929b9435326de176f667757efa4ce29ad8432c04c147d4f3fd1a143675890d7919a7b48ef0616b9d4e8422686b9798d1decfbb6405e0ccfeb15aaff986f5aed3e0c0fcf5a3d4b92ea1085f6fdfdb3f053c8c3e0b4File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
- Loading branch information
Uh oh!
There was an error while loading.Please reload this page.
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -580,6 +580,69 @@ def test_constructor(self): | ||
| self.assertIs(T.__bound__, None) | ||
| class TypeVarLikeDefaultsTests(BaseTestCase): | ||
| def test_typevar(self): | ||
| T = TypeVar('T', default=int) | ||
| self.assertEqual(T.__default__, int) | ||
| self.assertIsInstance(T, TypeVar) | ||
| class A(Generic[T]): ... | ||
| Alias = Optional[T] | ||
| def test_typevar_none(self): | ||
| U = TypeVar('U') | ||
| U_None = TypeVar('U_None', default=None) | ||
| self.assertEqual(U.__default__, None) | ||
| self.assertEqual(U_None.__default__, type(None)) | ||
| def test_paramspec(self): | ||
| P = ParamSpec('P', default=(str, int)) | ||
| self.assertEqual(P.__default__, (str, int)) | ||
| self.assertIsInstance(P, ParamSpec) | ||
| class A(Generic[P]): ... | ||
| Alias = typing.Callable[P, None] | ||
| P_default = ParamSpec('P_default', default=...) | ||
| self.assertIs(P_default.__default__, ...) | ||
| def test_paramspec_none(self): | ||
| U = ParamSpec('U') | ||
| U_None = ParamSpec('U_None', default=None) | ||
| self.assertEqual(U.__default__, None) | ||
| self.assertEqual(U_None.__default__, type(None)) | ||
| def test_typevartuple(self): | ||
| Ts = TypeVarTuple('Ts', default=Unpack[Tuple[str, int]]) | ||
| self.assertEqual(Ts.__default__, Unpack[Tuple[str, int]]) | ||
| self.assertIsInstance(Ts, TypeVarTuple) | ||
| class A(Generic[Unpack[Ts]]): ... | ||
| Alias = Optional[Unpack[Ts]] | ||
| def test_typevartuple_none(self): | ||
| U = TypeVarTuple('U') | ||
| U_None = TypeVarTuple('U_None', default=None) | ||
| self.assertEqual(U.__default__, None) | ||
| self.assertEqual(U_None.__default__, type(None)) | ||
| def test_pickle(self): | ||
| global U, U_co, U_contra, U_default # pickle wants to reference the class by name | ||
| U = TypeVar('U') | ||
| U_co = TypeVar('U_co', covariant=True) | ||
| U_contra = TypeVar('U_contra', contravariant=True) | ||
| U_default = TypeVar('U_default', default=int) | ||
| for proto in range(pickle.HIGHEST_PROTOCOL): | ||
| for typevar in (U, U_co, U_contra, U_default): | ||
| z = pickle.loads(pickle.dumps(typevar, proto)) | ||
| self.assertEqual(z.__name__, typevar.__name__) | ||
| self.assertEqual(z.__covariant__, typevar.__covariant__) | ||
| self.assertEqual(z.__contravariant__, typevar.__contravariant__) | ||
| self.assertEqual(z.__bound__, typevar.__bound__) | ||
| self.assertEqual(z.__default__, typevar.__default__) | ||
AlexWaygood marked this conversation as resolved. OutdatedShow resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
| def template_replace(templates: list[str], replacements: dict[str, list[str]]) -> list[tuple[str]]: | ||
| """Renders templates with possible combinations of replacements. | ||
Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.
Uh oh!
There was an error while loading.Please reload this page.
JelleZijlstra marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. |