Add test coverage for Python 3.12+ type params and PEP 701 f-strings#5245
Open
Emilianocarfu88 wants to merge 1 commit into
Open
Add test coverage for Python 3.12+ type params and PEP 701 f-strings#5245Emilianocarfu88 wants to merge 1 commit into
Emilianocarfu88 wants to merge 1 commit into
Conversation
Cover gaps around PEP 695 type parameters (incl. PEP 696 defaults), *TypeVarTuple/**ParamSpec, and PEP 701 f-strings, focusing on their interaction with line splitting and comment handling. - tests/data/cases/type_params_comments.py: comments inside type-param brackets (inline, leading/standalone, on bounds and constraint tuples) - tests/data/cases/type_param_defaults_comments.py: PEP 696 defaults with comments and wrapping - tests/data/cases/fstring_pep701_comments.py: comments in multiline interpolations, nested/quote-reuse f-strings, format specs, = debug, call-argument splitting - tests/data/cases/type_params_line_split.py: overflowing type-param lists, bounds/constraints, combined type-param + argument + return-type splitting - tests/test_pep695_701_properties.py: Hypothesis strategies for type-param lists and f-strings asserting idempotency (assert_stable) and AST safety (assert_equivalent) across varied modes - tests/test_regression_type_params.py: strict-xfail pinning psf#5243 (magic trailing comma fails to explode a type-param list containing *TypeVarTuple/**ParamSpec) Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Adds test coverage for Python 3.12+ syntax that was thin in the suite, focused on how
PEP 695 type parameters (incl. PEP 696 defaults,
*TypeVarTuple/**ParamSpec) andPEP 701 f-strings interact with Black's line splitting and comment handling.
New data-driven cases (auto-discovered by
test_simple_format, so each also runs Black'sbuilt-in AST-equivalence, idempotency/stability, preview, and line-length-1 checks):
tests/data/cases/type_params_comments.py— comments inside type-param brackets(inline, leading/standalone, on bounds and constraint tuples).
tests/data/cases/type_param_defaults_comments.py— PEP 696 defaults with comments andwrapping.
tests/data/cases/fstring_pep701_comments.py— comments in multiline interpolations,nested/quote-reuse f-strings, format specs,
=debug, call-argument splitting.tests/data/cases/type_params_line_split.py— overflowing type-param lists,bounds/constraints, combined type-param + argument + return-type splitting.
Property-based tests:
tests/test_pep695_701_properties.py— targeted Hypothesis strategies for type-paramlists and f-strings asserting idempotency (
assert_stable) and AST safety(
assert_equivalent) across varied modes (line lengths incl. 1, preview, magic-comma,string normalization). Every generated example is
compile()-checked first so astrategy bug can't masquerade as a Black bug. Mirrors the deterministic settings of
scripts/fuzz.py.Regression test:
tests/test_regression_type_params.py— a strict-xfailpinning Magic trailing comma does not explode a type-parameter list containing *TypeVarTuple / **ParamSpec #5243 (a magic trailingcomma fails to explode a type-param list once it contains
*TypeVarTuple/**ParamSpec).It asserts the desired exploded output, so when the bug is fixed the test XPASSes and the
strict marker turns that into a failure, prompting promotion to a normal data case.
All expected
# outputblocks were generated by running Black itself, never hand-written.Checklist
CHANGES.mdentry (happy to add one if preferred)Relates to #5243.