GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — gh-102444: Fix minor bugs in `test_typing` highlighted by pyflakes by AlexWaygood · Pull Request #102445 · python/cpython Conversation
|
| def test_hash_eq(self): | ||
| self.assertEqual(len({Annotated[int, 4, 5], Annotated[int, 4, 5]}), 1) | ||
| self.assertNotEqual(Annotated[int, 4, 5], Annotated[int, 5, 4]) | ||
| self.assertNotEqual(Annotated[int, 4, 5], Annotated[str, 4, 5]) | ||
| self.assertNotEqual(Annotated[int, 4], Annotated[int, 4, 4]) | ||
| self.assertEqual( | ||
| {Annotated[int, 4, 5], Annotated[int, 4, 5], Annotated[T, 4, 5]}, | ||
| {Annotated[int, 4, 5], Annotated[T, 4, 5]} | ||
| ) | ||
|
|
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
This test is exactly identical to test_hash_eq on line 7015:
cpython/Lib/test/test_typing.py
Lines 7015 to 7023 in 7894bbe
| def test_hash_eq(self): | |
| self.assertEqual(len({Annotated[int, 4, 5], Annotated[int, 4, 5]}), 1) | |
| self.assertNotEqual(Annotated[int, 4, 5], Annotated[int, 5, 4]) | |
| self.assertNotEqual(Annotated[int, 4, 5], Annotated[str, 4, 5]) | |
| self.assertNotEqual(Annotated[int, 4], Annotated[int, 4, 4]) | |
| self.assertEqual( | |
| {Annotated[int, 4, 5], Annotated[int, 4, 5], Annotated[T, 4, 5]}, | |
| {Annotated[int, 4, 5], Annotated[T, 4, 5]} | |
| ) |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
|
||
| def test_bad_var_substitution(self): | ||
| T = TypeVar('T') | ||
| P = ParamSpec("P") |
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
P here is currently an unused variable. ParamSpec.__typing_subst__ is tested in another place in this file:
cpython/Lib/test/test_typing.py
Lines 7528 to 7539 in 7894bbe
| def test_bad_var_substitution(self): | |
| T = TypeVar('T') | |
| P = ParamSpec('P') | |
| bad_args = (42, int, None, T, int|str, Union[int, str]) | |
| for arg in bad_args: | |
| with self.subTest(arg=arg): | |
| with self.assertRaises(TypeError): | |
| P.__typing_subst__(arg) | |
| with self.assertRaises(TypeError): | |
| typing.Callable[P, T][arg, str] | |
| with self.assertRaises(TypeError): | |
| collections.abc.Callable[P, T][arg, str] |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| self.assertEqual(B.__args__, ((int, str,), Tuple[bytes, float])) | ||
|
|
||
| def test_var_substitution(self): | ||
| T = TypeVar("T") |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
T here is currently an unused variable. TypeVar.__typing_subst__ is tested more fully elsewhere:
cpython/Lib/test/test_typing.py
Lines 461 to 472 in 7894bbe
| def test_var_substitution(self): | |
| T = TypeVar('T') | |
| subst = T.__typing_subst__ | |
| self.assertIs(subst(int), int) | |
| self.assertEqual(subst(list[int]), list[int]) | |
| self.assertEqual(subst(List[int]), List[int]) | |
| self.assertEqual(subst(List), List) | |
| self.assertIs(subst(Any), Any) | |
| self.assertIs(subst(None), type(None)) | |
| self.assertIs(subst(T), T) | |
| self.assertEqual(subst(int|str), int|str) | |
| self.assertEqual(subst(Union[int, str]), Union[int, str]) |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| # Definitions needed for features introduced in Python 3.6 | ||
|
|
||
| from test import ann_module, ann_module2, ann_module3, ann_module5, ann_module6 | ||
| import asyncio |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Typing in Python is definitely synchronous ;)
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| j = Callable[[None], Unpack[Ts]] | ||
| self.assertEqual(i.__args__, (type(None), *Ts)) | ||
| self.assertEqual(i.__args__, (type(None), Unpack[Ts])) | ||
| self.assertEqual(j.__args__, (type(None), Unpack[Ts])) |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
The j variable is currently unused. Given the pattern of the assertions immediately below, it seems pretty clear that it was meant to be used here.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Thanks @AlexWaygood for the PR 🌮🎉.. I'm working now to backport this PR to: 3.10, 3.11. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Sorry, @AlexWaygood, I could not cleanly backport this to |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
GH-102451 is a backport of this pull request to the 3.11 branch. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Thanks for the review @sobolevn! |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
…kes (pythonGH-102445) (cherry picked from commit 96e1022) Co-authored-by: Alex Waygood <[email protected]>
…y pyflakes (python#102445) (cherry picked from commit 96e1022)
|
GH-102452 is a backport of this pull request to the 3.10 branch. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
…H-102445) (cherry picked from commit 96e1022) Co-authored-by: Alex Waygood <[email protected]>
|
Sorry, something went wrong.
There was an error while loading. Please reload this page.
This method is identical to `test_hash_eq` on lines 2296-2304: https://github.com/python/typing_extensions/blob/a0858e6ba9b46996f3f74dde8749ab86e1561012/src/test_typing_extensions.py#L2296-L2304 (This is a backport of the only relevant part of python/cpython#102445)
This method is identical to `test_hash_eq` on lines 2296-2304: https://github.com/python/typing_extensions/blob/a0858e6ba9b46996f3f74dde8749ab86e1561012/src/test_typing_extensions.py#L2296-L2304 (This is a backport of the only relevant part of python/cpython#102445)
* main: (21 commits) pythongh-102192: Replace PyErr_Fetch/Restore etc by more efficient alternatives in sub interpreters module (python#102472) pythongh-95672: Fix versionadded indentation of get_pagesize in test.rst (pythongh-102455) pythongh-102416: Do not memoize incorrectly loop rules in the parser (python#102467) pythonGH-101362: Optimise PurePath(PurePath(...)) (pythonGH-101667) pythonGH-101362: Check pathlib.Path flavour compatibility at import time (pythonGH-101664) pythonGH-101362: Call join() only when >1 argument supplied to pathlib.PurePath() (python#101665) pythongh-102444: Fix minor bugs in `test_typing` highlighted by pyflakes (python#102445) pythonGH-102341: Improve the test function for pow (python#102342) Fix unused classes in a typing test (pythonGH-102437) pythongh-101979: argparse: fix a bug where parentheses in metavar argument of add_argument() were dropped (python#102318) pythongh-102356: Add thrashcan macros to filter object dealloc (python#102426) Move around example in to_bytes() to avoid confusion (python#101595) pythonGH-97546: fix flaky asyncio `test_wait_for_race_condition` test (python#102421) pythongh-96821: Add config option `--with-strict-overflow` (python#96823) pythongh-101992: update pstlib module documentation (python#102133) pythongh-63301: Set exit code when tabnanny CLI exits on error (python#7699) pythongh-101863: Fix wrong comments in EUC-KR codec (pythongh-102417) pythongh-102302 Micro-optimize `inspect.Parameter.__hash__` (python#102303) pythongh-102179: Fix `os.dup2` error reporting for negative fds (python#102180) pythongh-101892: Fix `SystemError` when a callable iterator call exhausts the iterator (python#101896) ...
* main: (37 commits) pythongh-102192: Replace PyErr_Fetch/Restore etc by more efficient alternatives in sub interpreters module (python#102472) pythongh-95672: Fix versionadded indentation of get_pagesize in test.rst (pythongh-102455) pythongh-102416: Do not memoize incorrectly loop rules in the parser (python#102467) pythonGH-101362: Optimise PurePath(PurePath(...)) (pythonGH-101667) pythonGH-101362: Check pathlib.Path flavour compatibility at import time (pythonGH-101664) pythonGH-101362: Call join() only when >1 argument supplied to pathlib.PurePath() (python#101665) pythongh-102444: Fix minor bugs in `test_typing` highlighted by pyflakes (python#102445) pythonGH-102341: Improve the test function for pow (python#102342) Fix unused classes in a typing test (pythonGH-102437) pythongh-101979: argparse: fix a bug where parentheses in metavar argument of add_argument() were dropped (python#102318) pythongh-102356: Add thrashcan macros to filter object dealloc (python#102426) Move around example in to_bytes() to avoid confusion (python#101595) pythonGH-97546: fix flaky asyncio `test_wait_for_race_condition` test (python#102421) pythongh-96821: Add config option `--with-strict-overflow` (python#96823) pythongh-101992: update pstlib module documentation (python#102133) pythongh-63301: Set exit code when tabnanny CLI exits on error (python#7699) pythongh-101863: Fix wrong comments in EUC-KR codec (pythongh-102417) pythongh-102302 Micro-optimize `inspect.Parameter.__hash__` (python#102303) pythongh-102179: Fix `os.dup2` error reporting for negative fds (python#102180) pythongh-101892: Fix `SystemError` when a callable iterator call exhausts the iterator (python#101896) ...
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.