Skip to content

Conversation

@moreal
Copy link
Contributor

@moreal moreal commented Jan 21, 2026

Note

I'm trying to fixing the following issue.

This pull request makes the deps subcommand show tests that depend on a given module. This is to speed up the feedback loop, as while CI does run the tests, waiting for it takes quite a long time.

Running it like python3 scripts/update_lib deps json --dependent-tests-only will output just the list of tests without any verbose logs, which can then be passed directly as arguments after -m test.

However, when you check with the command ls Lib/test | grep "test_" | wc -l, there are about 342 tests in total, and even with this feature, the number only drops to around 330, so it doesn't feel very useful.

# When running python3 scripts/update_lib deps json
[+] lib: cpython/Lib/json
[+] test: cpython/Lib/test/test_json
soft_deps:
- [ ] json (native: _json, decoder, encoder, sys)
  - [ ] codecs (native: _codecs, builtins, sys)
    - [ ] encodings (native: _codecs_cn, _codecs_hk, _codecs_iso2022, _codecs_jp, _codecs_kr, _codecs_tw, _multibytecodec, _win_cp_codecs, binascii, sys, unicodedata, zlib)
      - [ ] io (native: _io, _thread, errno, msvcrt, sys)
        - [ ] locale (native: _locale, builtins, sys)
          - [ ] os (native: nt, posix, sys)
            - [ ] ntpath (native: _winapi, nt, sys)
              - [ ] os
              - [x] genericpath, re
            - [ ] posixpath (native: errno, posix, pwd, sys)
              - [ ] os
              - [x] genericpath, re, stat
            - [ ] subprocess (native: _posixsubprocess, _winapi, builtins, errno, fcntl, grp, msvcrt, pwd, select, sys, time)
              - [ ] types (native: _types, sys)
                - [x] _collections_abc, functools
              - [ ] io, locale, os
              - [x] contextlib, selectors, signal, threading, warnings
            - [ ] io
            - [x] _collections_abc, abc, stat, warnings
          - [ ] encodings
          - [x] _collections_abc, functools, re, warnings
        - [ ] os (native: nt, posix, sys)
          - [ ] io, ntpath, posixpath, subprocess
          - [x] _collections_abc, abc, stat, warnings
        - [ ] codecs
        - [x] _collections_abc, abc, stat, warnings
      - [ ] quopri (native: binascii, sys)
        - [ ] getopt (native: sys)
          - [ ] gettext (native: builtins, errno, sys)
            - [ ] copy
              - [ ] copyreg
                - [ ] operator (native: _operator, builtins)
                  - [x] functools
                - [x] typing
              - [ ] weakref (native: _weakref, atexit, gc, itertools, sys)
                - [ ] _weakrefset (native: _weakref)
                  - [ ] types
                - [ ] copy
                - [x] _collections_abc
              - [ ] types
            - [ ] operator (native: _operator, builtins)
              - [x] functools
            - [ ] locale, os
            - [x] re, struct, warnings
          - [ ] os
        - [ ] io
      - [ ] codecs
      - [x] base64, bz2, re, stringprep
    - [x] warnings
  - [x] _colorize, argparse, re
[+] dependent tests: (333 tests depend on json)
  - test___all__
  - test__colorize
  - test__opcode
  - test__osx_support
  - test_abc
  - test_abstract_numbers
  - test_android
  - test_argparse
  - test_array
  - test_ast
  - test_asyncgen
  - test_atexit
  - test_audit
  - test_augassign
  - test_base64
  - test_baseexception
  - test_bdb
  - test_bigaddrspace
  - test_bigmem
  - test_binascii
  - test_binop
  - test_bisect
  - test_bool
  - test_buffer
  - test_bufio
  - test_builtin
  - test_bytes
  - test_bz2
  - test_c_locale_coercion
  - test_calendar
  - test_call
  - test_charmapcodec
  - test_class
  - test_cmath
  - test_cmd
  - test_cmd_line
  - test_cmd_line_script
  - test_code
  - test_code_module
  - test_codeccallbacks
  - test_codecs
  - test_codeop
  - test_collections
  - test_colorsys
  - test_compare
  - test_compile
  - test_compileall
  - test_compiler_assemble
  - test_compiler_codegen
  - test_complex
  - test_concurrent_futures
  - test_configparser
  - test_contains
  - test_context
  - test_contextlib
  - test_contextlib_async
  - test_copy
  - test_copyreg
  - test_csv
  - test_ctypes
  - test_datetime
  - test_dbm
  - test_dbm_dumb
  - test_dbm_sqlite3
  - test_decimal
  - test_decorators
  - test_defaultdict
  - test_deque
  - test_descr
  - test_descrtut
  - test_devpoll
  - test_dict
  - test_dictcomps
  - test_dictviews
  - test_difflib
  - test_dis
  - test_doctest
  - test_doctest2
  - test_docxmlrpc
  - test_dtrace
  - test_dummy_thread
  - test_dummy_threading
  - test_dynamic
  - test_dynamicclassattribute
  - test_eintr
  - test_email
  - test_ensurepip
  - test_enum
  - test_enumerate
  - test_eof
  - test_epoll
  - test_errno
  - test_except_star
  - test_exception_group
  - test_exception_hierarchy
  - test_exception_variations
  - test_exceptions
  - test_faulthandler
  - test_fcntl
  - test_file
  - test_file_eintr
  - test_filecmp
  - test_fileinput
  - test_fileio
  - test_float
  - test_fnmatch
  - test_format
  - test_fractions
  - test_fstring
  - test_ftplib
  - test_funcattrs
  - test_functools
  - test_future_stmt
  - test_generators
  - test_genericalias
  - test_genericclass
  - test_genericpath
  - test_getopt
  - test_getpass
  - test_gettext
  - test_glob
  - test_global
  - test_grammar
  - test_graphlib
  - test_grp
  - test_gzip
  - test_hash
  - test_hashlib
  - test_heapq
  - test_hmac
  - test_html
  - test_htmlparser
  - test_http_cookiejar
  - test_http_cookies
  - test_httplib
  - test_httpservers
  - test_importlib
  - test_index
  - test_inspect
  - test_int
  - test_int_literal
  - test_io
  - test_ioctl
  - test_ipaddress
  - test_isinstance
  - test_iter
  - test_iterlen
  - test_itertools
  - test_json
  - test_keyword
  - test_keywordonlyarg
  - test_kqueue
  - test_largefile
  - test_linecache
  - test_list
  - test_listcomps
  - test_locale
  - test_logging
  - test_long
  - test_longexp
  - test_lzma
  - test_mailbox
  - test_marshal
  - test_math
  - test_math_property
  - test_memoryio
  - test_memoryview
  - test_mimetypes
  - test_mmap
  - test_multiprocessing_fork
  - test_multiprocessing_forkserver
  - test_multiprocessing_main_handling
  - test_multiprocessing_spawn
  - test_named_expressions
  - test_netrc
  - test_ntpath
  - test_numeric_tower
  - test_opcache
  - test_opcodes
  - test_openpty
  - test_operator
  - test_optparse
  - test_ordered_dict
  - test_os
  - test_pathlib
  - test_patma
  - test_peepholer
  - test_pickle
  - test_picklebuffer
  - test_pickletools
  - test_pkg
  - test_pkgutil
  - test_platform
  - test_plistlib
  - test_poll
  - test_popen
  - test_positional_only_arg
  - test_posix
  - test_posixpath
  - test_pow
  - test_pprint
  - test_print
  - test_property
  - test_pty
  - test_pulldom
  - test_pwd
  - test_py_compile
  - test_pyclbr
  - test_pyexpat
  - test_queue
  - test_quopri
  - test_raise
  - test_random
  - test_range
  - test_re
  - test_regrtest
  - test_repl
  - test_reprlib
  - test_resource
  - test_richcmp
  - test_rlcompleter
  - test_robotparser
  - test_runpy
  - test_sched
  - test_scope
  - test_script_helper
  - test_secrets
  - test_selectors
  - test_set
  - test_setcomps
  - test_shelve
  - test_shlex
  - test_shutil
  - test_signal
  - test_site
  - test_slice
  - test_smtplib
  - test_smtpnet
  - test_socket
  - test_socketserver
  - test_sort
  - test_sqlite3
  - test_ssl
  - test_stat
  - test_statistics
  - test_str
  - test_strftime
  - test_string
  - test_string_literals
  - test_stringprep
  - test_strtod
  - test_struct
  - test_structseq
  - test_subclassinit
  - test_subprocess
  - test_sundry
  - test_super
  - test_support
  - test_symtable
  - test_syntax
  - test_sys
  - test_sys_setprofile
  - test_sys_settrace
  - test_sysconfig
  - test_syslog
  - test_tabnanny
  - test_tarfile
  - test_tempfile
  - test_textwrap
  - test_thread
  - test_threadedtempfile
  - test_threading
  - test_threading_local
  - test_time
  - test_timeit
  - test_timeout
  - test_tokenize
  - test_tomllib
  - test_tools
  - test_trace
  - test_traceback
  - test_tty
  - test_tuple
  - test_type_comments
  - test_typechecks
  - test_types
  - test_typing
  - test_ucn
  - test_unary
  - test_unicode_file
  - test_unicode_file_functions
  - test_unicode_identifiers
  - test_unicodedata
  - test_unittest
  - test_univnewlines
  - test_unpack
  - test_urllib
  - test_urllib2
  - test_urllib2_localnet
  - test_urllib2net
  - test_urllib_response
  - test_urllibnet
  - test_urlparse
  - test_userdict
  - test_userlist
  - test_userstring
  - test_utf8_mode
  - test_utf8source
  - test_uuid
  - test_venv
  - test_wait3
  - test_wait4
  - test_wave
  - test_weakref
  - test_weakset
  - test_webbrowser
  - test_winapi
  - test_winreg
  - test_with
  - test_wsgiref
  - test_xml_dom_minicompat
  - test_xml_dom_xmlbuilder
  - test_xml_etree
  - test_xml_etree_c
  - test_xmlrpc
  - test_yield_from
  - test_zipapp
  - test_zipfile
  - test_zipfile64
  - test_zipimport
  - test_zlib
  - test_zoneinfo
  - test_zstd

With --dependent-tests-only option:

test___all__ test__colorize test__opcode test__osx_support test_abc test_abstract_numbers test_android test_argparse test_array test_ast test_asyncgen test_atexit test_audit test_augassign test_base64 test_baseexception test_bdb test_bigaddrspace test_bigmem test_binascii test_binop test_bisect test_bool test_buffer test_bufio test_builtin test_bytes test_bz2 test_c_locale_coercion test_calendar test_call test_charmapcodec test_class test_cmath test_cmd test_cmd_line test_cmd_line_script test_code test_code_module test_codeccallbacks test_codecs test_codeop test_collections test_colorsys test_compare test_compile test_compileall test_compiler_assemble test_compiler_codegen test_complex test_concurrent_futures test_configparser test_contains test_context test_contextlib test_contextlib_async test_copy test_copyreg test_csv test_ctypes test_datetime test_dbm test_dbm_dumb test_dbm_sqlite3 test_decimal test_decorators test_defaultdict test_deque test_descr test_descrtut test_devpoll test_dict test_dictcomps test_dictviews test_difflib test_dis test_doctest test_doctest2 test_docxmlrpc test_dtrace test_dummy_thread test_dummy_threading test_dynamic test_dynamicclassattribute test_eintr test_email test_ensurepip test_enum test_enumerate test_eof test_epoll test_errno test_except_star test_exception_group test_exception_hierarchy test_exception_variations test_exceptions test_faulthandler test_fcntl test_file test_file_eintr test_filecmp test_fileinput test_fileio test_float test_fnmatch test_format test_fractions test_fstring test_ftplib test_funcattrs test_functools test_future_stmt test_generators test_genericalias test_genericclass test_genericpath test_getopt test_getpass test_gettext test_glob test_global test_grammar test_graphlib test_grp test_gzip test_hash test_hashlib test_heapq test_hmac test_html test_htmlparser test_http_cookiejar test_http_cookies test_httplib test_httpservers test_importlib test_index test_inspect test_int test_int_literal test_io test_ioctl test_ipaddress test_isinstance test_iter test_iterlen test_itertools test_json test_keyword test_keywordonlyarg test_kqueue test_largefile test_linecache test_list test_listcomps test_locale test_logging test_long test_longexp test_lzma test_mailbox test_marshal test_math test_math_property test_memoryio test_memoryview test_mimetypes test_mmap test_multiprocessing_fork test_multiprocessing_forkserver test_multiprocessing_main_handling test_multiprocessing_spawn test_named_expressions test_netrc test_ntpath test_numeric_tower test_opcache test_opcodes test_openpty test_operator test_optparse test_ordered_dict test_os test_pathlib test_patma test_peepholer test_pickle test_picklebuffer test_pickletools test_pkg test_pkgutil test_platform test_plistlib test_poll test_popen test_positional_only_arg test_posix test_posixpath test_pow test_pprint test_print test_property test_pty test_pulldom test_pwd test_py_compile test_pyclbr test_pyexpat test_queue test_quopri test_raise test_random test_range test_re test_regrtest test_repl test_reprlib test_resource test_richcmp test_rlcompleter test_robotparser test_runpy test_sched test_scope test_script_helper test_secrets test_selectors test_set test_setcomps test_shelve test_shlex test_shutil test_signal test_site test_slice test_smtplib test_smtpnet test_socket test_socketserver test_sort test_sqlite3 test_ssl test_stat test_statistics test_str test_strftime test_string test_string_literals test_stringprep test_strtod test_struct test_structseq test_subclassinit test_subprocess test_sundry test_super test_support test_symtable test_syntax test_sys test_sys_setprofile test_sys_settrace test_sysconfig test_syslog test_tabnanny test_tarfile test_tempfile test_textwrap test_thread test_threadedtempfile test_threading test_threading_local test_time test_timeit test_timeout test_tokenize test_tomllib test_tools test_trace test_traceback test_tty test_tuple test_type_comments test_typechecks test_types test_typing test_ucn test_unary test_unicode_file test_unicode_file_functions test_unicode_identifiers test_unicodedata test_unittest test_univnewlines test_unpack test_urllib test_urllib2 test_urllib2_localnet test_urllib2net test_urllib_response test_urllibnet test_urlparse test_userdict test_userlist test_userstring test_utf8_mode test_utf8source test_uuid test_venv test_wait3 test_wait4 test_wave test_weakref test_weakset test_webbrowser test_winapi test_winreg test_with test_wsgiref test_xml_dom_minicompat test_xml_dom_xmlbuilder test_xml_etree test_xml_etree_c test_xmlrpc test_yield_from test_zipapp test_zipfile test_zipfile64 test_zipimport test_zlib test_zoneinfo test_zstd

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 21, 2026

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@youknowone youknowone added the skip:ci Skip running the ci label Jan 21, 2026
@youknowone
Copy link
Member

I suggest to include it as default output, dependents

[+] dependents: (343 tests depend on reprlib)
  test___all__  test__colorize test__opcode test__osx_support test_abc ...

Then this is copyable to -m test.

Output like current way when --verbose is given

moreal and others added 8 commits January 21, 2026 21:59
Extend find_tests_importing_module() and _build_test_import_graph() to
recursively search Lib/test/test_*/ directories using **/*.py glob
pattern instead of just *.py.

This fixes incomplete dependency analysis that was missing test files
inside module directories like test_json/, test_importlib/, etc.

Changes:
- Add _parse_test_submodule_imports() to handle "from test.X import Y"
- Update _build_test_import_graph() with recursive glob and submodule
  import handling
- Update find_tests_importing_module() to use relative paths and handle
  __init__.py files correctly
- Update show_deps.py to display relative paths (e.g., test_json/test_decode.py)
- Add TestFindTestsInModuleDirectories test class with 3 tests

Co-Authored-By: Claude <noreply@anthropic.com>
Add consolidate_test_paths() to group test_*/ directory contents into
single entries (e.g., test_sqlite3/test_dbapi.py → test_sqlite3).

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Outputs space-separated test names for direct use with python3 -m test:
  python3 -m test $(python3 scripts/update_lib deps sqlite3 --impact-only)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Remove --impact flag, dependent tests are now shown by default
- Rename --impact-only to --dependent-tests-only
- Change output label from "[+] impact:" to "[+] dependent tests:"

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@github-actions
Copy link
Contributor

Code has been automatically formatted

The code in this PR has been formatted using:

  • ruff format
    Please pull the latest changes before pushing again:
git pull origin deps-impact-command

@moreal moreal changed the title [update_lib] --impact option for deps subcommand [update_lib] show dependent tests in deps subcommand Jan 21, 2026
@moreal
Copy link
Contributor Author

moreal commented Jan 21, 2026

I've made some more modifications. However, as I noted in the PR description, the outcome isn't significantly different from a complete overhaul, so I'm questioning its effectiveness. It might be better to just close it.

@moreal moreal marked this pull request as ready for review January 21, 2026 15:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip:ci Skip running the ci

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants