FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-102444: Fix minor bugs in `test_typing` highlighted by pyflakes by AlexWaygood · Pull Request #102445 · python/cpython · GitHub

Repository navigation

gh-102444: Fix minor bugs in test_typing highlighted by pyflakes - #102445

Merged
AlexWaygood merged 1 commit into
python:mainfrom
AlexWaygood:pyflakes-typing-tests
Mar 5, 2023
Merged

AlexWaygood merged 1 commit into
python:mainfrom
AlexWaygood:pyflakes-typing-tests

Conversation

AlexWaygood commented Mar 5, 2023 •
edited by bedevere-bot
Loading

Copy link
Copy Markdown
Member

Comment thread Lib/test/test_typing.py
Comment on lines -7080 to -7089
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]}
)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

This test is exactly identical to test_hash_eq on line 7015:

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]}
)

Comment thread Lib/test/test_typing.py

def test_bad_var_substitution(self):
T = TypeVar('T')
P = ParamSpec("P")

AlexWaygood Mar 5, 2023 •
edited
Loading

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

P here is currently an unused variable. ParamSpec.__typing_subst__ is tested in another place in this file:

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]

Comment thread Lib/test/test_typing.py
self.assertEqual(B.__args__, ((int, str,), Tuple[bytes, float]))

def test_var_substitution(self):
T = TypeVar("T")

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

T here is currently an unused variable. TypeVar.__typing_subst__ is tested more fully elsewhere:

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])

Comment thread Lib/test/test_typing.py
# Definitions needed for features introduced in Python 3.6

from test import ann_module, ann_module2, ann_module3, ann_module5, ann_module6
import asyncio

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Typing in Python is definitely synchronous ;)

Comment thread Lib/test/test_typing.py
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]))

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

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.

AlexWaygood requested a review from sobolevn March 5, 2023 18:33

sobolevn left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Thank you!

AlexWaygood merged commit 96e1022 into python:main Mar 5, 2023

Copy link
Copy Markdown
Contributor

Thanks @AlexWaygood for the PR 🌮🎉.. I'm working now to backport this PR to: 3.10, 3.11.
🐍🍒⛏🤖

AlexWaygood deleted the pyflakes-typing-tests branch March 5, 2023 21:37

Copy link
Copy Markdown
Contributor

Sorry, @AlexWaygood, I could not cleanly backport this to 3.10 due to a conflict.
Please backport using cherry_picker on command line.
cherry_picker 96e10229292145012bc462a6ab3ce1626c8acf71 3.10

Copy link
Copy Markdown

GH-102451 is a backport of this pull request to the 3.11 branch.

bedevere-bot removed the needs backport to 3.11 only security fixes label Mar 5, 2023

Copy link
Copy Markdown
Member Author

Thanks for the review @sobolevn!

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Mar 5, 2023
…kes (pythonGH-102445)

(cherry picked from commit 96e1022)

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
AlexWaygood added a commit to AlexWaygood/cpython that referenced this pull request Mar 5, 2023

Copy link
Copy Markdown

GH-102452 is a backport of this pull request to the 3.10 branch.

miss-islington added a commit that referenced this pull request Mar 5, 2023
…H-102445)

(cherry picked from commit 96e1022)

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
AlexWaygood added a commit that referenced this pull request Mar 5, 2023

Copy link
Copy Markdown

⚠️⚠️⚠️ Buildbot failure ⚠️⚠️⚠️

Hi! The buildbot s390x Fedora LTO 3.11 has failed when building commit a7ec32e.

What do you need to do:

  1. Don't panic.
  2. Check the buildbot page in the devguide if you don't know what the buildbots are or how they work.
  3. Go to the page of the buildbot that failed (https://buildbot.python.org/all/#builders/975/builds/592) and take a look at the build logs.
  4. Check if the failure is related to this commit (a7ec32e) or if it is a false positive.
  5. If the failure is related to this commit, please, reflect that on the issue and make a new Pull Request with a fix.

You can take a look at the buildbot page here:

https://buildbot.python.org/all/#builders/975/builds/592

Failed tests:

  • test_tools

Failed subtests:

  • test_freeze_simple_script - test.test_tools.test_freeze.TestFreeze.test_freeze_simple_script

Summary of the results of the build (if available):

== Tests result: FAILURE then FAILURE ==

418 tests OK.

10 slowest tests:

  • test_tools: 5 min 40 sec
  • test_concurrent_futures: 2 min 19 sec
  • test_gdb: 2 min 2 sec
  • test_multiprocessing_spawn: 1 min 28 sec
  • test_multiprocessing_forkserver: 1 min 12 sec
  • test_asyncio: 1 min 6 sec
  • test_multiprocessing_fork: 1 min 6 sec
  • test_signal: 47.2 sec
  • test_socket: 44.5 sec
  • test_io: 34.6 sec

1 test failed:
test_tools

15 tests skipped:
test_devpoll test_ioctl test_kqueue test_launcher test_msilib
test_nis test_readline test_startfile test_tix test_tk
test_ttk_guionly test_winconsoleio test_winreg test_winsound
test_zipfile64

1 re-run test:
test_tools

Total duration: 12 min 34 sec

Click to see traceback logs
Traceback (most recent call last):
  File "/home/dje/cpython-buildarea/3.11.edelsohn-fedora-z.lto/build/Lib/multiprocessing/resource_tracker.py", line 209, in main
    cache[rtype].remove(name)
KeyError: '/psm_f57c1e4e'


Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/tmp/tmpfdy_793g/cpython/Lib/sysconfig.py", line 715, in get_config_var
    return get_config_vars().get(name)
           ^^^^^^^^^^^^^^^^^
  File "/tmp/tmpfdy_793g/cpython/Lib/sysconfig.py", line 670, in get_config_vars
    _init_posix(_CONFIG_VARS)
  File "/tmp/tmpfdy_793g/cpython/Lib/sysconfig.py", line 531, in _init_posix
    _temp = __import__(name, globals(), locals(), ['build_time_vars'], 0)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ModuleNotFoundError: No module named '_sysconfigdata__linux_s390x-linux-gnu'


Traceback (most recent call last):
  File "/home/dje/cpython-buildarea/3.11.edelsohn-fedora-z.lto/build/Lib/multiprocessing/resource_tracker.py", line 209, in main
    cache[rtype].remove(name)
KeyError: '/psm_74dbee9f'


Traceback (most recent call last):
  File "/home/dje/cpython-buildarea/3.11.edelsohn-fedora-z.lto/build/Lib/test/test_tools/test_freeze.py", line 28, in test_freeze_simple_script
    executable = helper.freeze(python, scriptfile, outdir)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/dje/cpython-buildarea/3.11.edelsohn-fedora-z.lto/build/Tools/freeze/test/freeze.py", line 197, in freeze
    _run_quiet([python, '-E', FREEZE, '-o', outdir, scriptfile], outdir)
  File "/home/dje/cpython-buildarea/3.11.edelsohn-fedora-z.lto/build/Tools/freeze/test/freeze.py", line 25, in _run_quiet
    return subprocess.run(
           ^^^^^^^^^^^^^^^
  File "/home/dje/cpython-buildarea/3.11.edelsohn-fedora-z.lto/build/Lib/subprocess.py", line 571, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['/tmp/tmpfdy_793g/python-installation/bin/python3', '-E', '/home/dje/cpython-buildarea/3.11.edelsohn-fedora-z.lto/build/Tools/freeze/freeze.py', '-o', '/tmp/tmpfdy_793g', '/tmp/tmpfdy_793g/app.py']' returned non-zero exit status 1.


Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/tmp/tmphfwnw525/cpython/Lib/sysconfig.py", line 715, in get_config_var
    return get_config_vars().get(name)
           ^^^^^^^^^^^^^^^^^
  File "/tmp/tmphfwnw525/cpython/Lib/sysconfig.py", line 670, in get_config_vars
    _init_posix(_CONFIG_VARS)
  File "/tmp/tmphfwnw525/cpython/Lib/sysconfig.py", line 531, in _init_posix
    _temp = __import__(name, globals(), locals(), ['build_time_vars'], 0)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ModuleNotFoundError: No module named '_sysconfigdata__linux_s390x-linux-gnu'


Traceback (most recent call last):
  File "/home/dje/cpython-buildarea/3.11.edelsohn-fedora-z.lto/build/Lib/multiprocessing/resource_tracker.py", line 209, in main
    cache[rtype].remove(name)
KeyError: '/psm_f59d9c7c'


Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/tmp/tmphfwnw525/cpython/Lib/ensurepip/__main__.py", line 5, in <module>
    sys.exit(ensurepip._main())
             ^^^^^^^^^^^^^^^^^
  File "/tmp/tmphfwnw525/cpython/Lib/ensurepip/__init__.py", line 286, in _main
    return _bootstrap(
           ^^^^^^^^^^^
  File "/tmp/tmphfwnw525/cpython/Lib/ensurepip/__init__.py", line 202, in _bootstrap
    return _run_pip([*args, *_PACKAGE_NAMES], additional_paths)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/tmp/tmphfwnw525/cpython/Lib/ensurepip/__init__.py", line 103, in _run_pip
    return subprocess.run(cmd, check=True).returncode
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/tmp/tmphfwnw525/cpython/Lib/subprocess.py", line 571, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['/tmp/tmphfwnw525/python-build/python', '-W', 'ignore::DeprecationWarning', '-c', '\nimport runpy\nimport sys\nsys.path = [\'/tmp/tmp2yrhi4m8/setuptools-65.5.0-py3-none-any.whl\', \'/tmp/tmp2yrhi4m8/pip-22.3.1-py3-none-any.whl\'] + sys.path\nsys.argv[1:] = [\'install\', \'--no-cache-dir\', \'--no-index\', \'--find-links\', \'/tmp/tmp2yrhi4m8\', \'--root\', \'/\', \'--upgrade\', \'setuptools\', \'pip\']\nrunpy.run_module("pip", run_name="__main__", alter_sys=True)\n']' returned non-zero exit status 1.
make[1]: *** [Makefile:1878: install] Error 1


Traceback (most recent call last):
  File "/home/dje/cpython-buildarea/3.11.edelsohn-fedora-z.lto/build/Lib/test/test_tools/test_freeze.py", line 27, in test_freeze_simple_script
    outdir, scriptfile, python = helper.prepare(script, outdir)
                                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/dje/cpython-buildarea/3.11.edelsohn-fedora-z.lto/build/Tools/freeze/test/freeze.py", line 184, in prepare
    _run_quiet([MAKE, '-C', builddir, 'install'])
  File "/home/dje/cpython-buildarea/3.11.edelsohn-fedora-z.lto/build/Tools/freeze/test/freeze.py", line 25, in _run_quiet
    return subprocess.run(
           ^^^^^^^^^^^^^^^
  File "/home/dje/cpython-buildarea/3.11.edelsohn-fedora-z.lto/build/Lib/subprocess.py", line 571, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['/usr/bin/make', '-C', '/tmp/tmphfwnw525/python-build', 'install']' returned non-zero exit status 2.


Traceback (most recent call last):
  File "/home/dje/cpython-buildarea/3.11.edelsohn-fedora-z.lto/build/Tools/freeze/freeze.py", line 489, in <module>
    main()
  File "/home/dje/cpython-buildarea/3.11.edelsohn-fedora-z.lto/build/Tools/freeze/freeze.py", line 387, in main
    files = makefreeze.makefreeze(base, dict, debug, custom_entry_point,
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/dje/cpython-buildarea/3.11.edelsohn-fedora-z.lto/build/Tools/freeze/makefreeze.py", line 52, in makefreeze
    writecode(outfp, mangled, str)
  File "/home/dje/cpython-buildarea/3.11.edelsohn-fedora-z.lto/build/Tools/freeze/makefreeze.py", line 83, in writecode
    print('%d,' % c, file=fp, end='')
OSError: [Errno 28] No space left on device

AlexWaygood added a commit to AlexWaygood/typing_extensions that referenced this pull request Mar 6, 2023
JelleZijlstra pushed a commit to python/typing_extensions that referenced this pull request Mar 6, 2023
hugovk pushed a commit to hugovk/cpython that referenced this pull request Mar 6, 2023
carljm added a commit to carljm/cpython that referenced this pull request Mar 6, 2023
* 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)
  ...
carljm added a commit to carljm/cpython that referenced this pull request Mar 7, 2023
* 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)
  ...
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip news tests Tests in the Lib/test dir

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants


Back | FazBrowse Home | New Git URL