Skip to content

Comments

Support formatting pycon markdown code blocks#23112

Merged
amyreese merged 9 commits intomainfrom
amy/markdown-pycon-blocks
Feb 9, 2026
Merged

Support formatting pycon markdown code blocks#23112
amyreese merged 9 commits intomainfrom
amy/markdown-pycon-blocks

Conversation

@amyreese
Copy link
Member

@amyreese amyreese commented Feb 6, 2026

Fix #23078

@amyreese amyreese requested a review from ntBre February 6, 2026 02:31
@amyreese
Copy link
Member Author

amyreese commented Feb 6, 2026

Still needs tests

@astral-sh-bot
Copy link

astral-sh-bot bot commented Feb 6, 2026

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

✅ ecosystem check detected no linter changes.

Copy link
Contributor

@ntBre ntBre left a comment

Choose a reason for hiding this comment

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

I wan to take a closer look at how this works in the docstring formatting, but this looks plausible to me in general.

@astral-sh-bot
Copy link

astral-sh-bot bot commented Feb 6, 2026

Typing conformance results

No changes detected ✅

@astral-sh-bot
Copy link

astral-sh-bot bot commented Feb 6, 2026

mypy_primer results

Changes were detected when running on open source projects
pydantic (https://github.com/pydantic/pydantic)
- pydantic/_internal/_core_metadata.py:87:54: error[invalid-assignment] Invalid assignment to key "pydantic_js_extra" with declared type `dict[str, Divergent] | ((dict[str, Divergent], /) -> None) | ((dict[str, Divergent], type[Any], /) -> None)` on TypedDict `CoreMetadata`: value of type `dict[object, object]`
+ pydantic/_internal/_core_metadata.py:87:54: error[invalid-assignment] Invalid assignment to key "pydantic_js_extra" with declared type `dict[str, int | float | str | ... omitted 3 union elements] | ((dict[str, int | float | str | ... omitted 3 union elements], /) -> None) | ((dict[str, int | float | str | ... omitted 3 union elements], type[Any], /) -> None)` on TypedDict `CoreMetadata`: value of type `dict[object, object]`
- pydantic/fields.py:949:5: error[invalid-parameter-default] Default value of type `PydanticUndefinedType` is not assignable to annotated parameter type `dict[str, Divergent] | ((dict[str, Divergent], /) -> None) | None`
+ pydantic/fields.py:949:5: error[invalid-parameter-default] Default value of type `PydanticUndefinedType` is not assignable to annotated parameter type `dict[str, int | float | str | ... omitted 3 union elements] | ((dict[str, int | float | str | ... omitted 3 union elements], /) -> None) | None`
- pydantic/fields.py:989:5: error[invalid-parameter-default] Default value of type `PydanticUndefinedType` is not assignable to annotated parameter type `dict[str, Divergent] | ((dict[str, Divergent], /) -> None) | None`
+ pydantic/fields.py:989:5: error[invalid-parameter-default] Default value of type `PydanticUndefinedType` is not assignable to annotated parameter type `dict[str, int | float | str | ... omitted 3 union elements] | ((dict[str, int | float | str | ... omitted 3 union elements], /) -> None) | None`
- pydantic/fields.py:1032:5: error[invalid-parameter-default] Default value of type `PydanticUndefinedType` is not assignable to annotated parameter type `dict[str, Divergent] | ((dict[str, Divergent], /) -> None) | None`
+ pydantic/fields.py:1032:5: error[invalid-parameter-default] Default value of type `PydanticUndefinedType` is not assignable to annotated parameter type `dict[str, int | float | str | ... omitted 3 union elements] | ((dict[str, int | float | str | ... omitted 3 union elements], /) -> None) | None`
- pydantic/fields.py:1072:5: error[invalid-parameter-default] Default value of type `PydanticUndefinedType` is not assignable to annotated parameter type `dict[str, Divergent] | ((dict[str, Divergent], /) -> None) | None`
+ pydantic/fields.py:1072:5: error[invalid-parameter-default] Default value of type `PydanticUndefinedType` is not assignable to annotated parameter type `dict[str, int | float | str | ... omitted 3 union elements] | ((dict[str, int | float | str | ... omitted 3 union elements], /) -> None) | None`
- pydantic/fields.py:1115:5: error[invalid-parameter-default] Default value of type `PydanticUndefinedType` is not assignable to annotated parameter type `dict[str, Divergent] | ((dict[str, Divergent], /) -> None) | None`
+ pydantic/fields.py:1115:5: error[invalid-parameter-default] Default value of type `PydanticUndefinedType` is not assignable to annotated parameter type `dict[str, int | float | str | ... omitted 3 union elements] | ((dict[str, int | float | str | ... omitted 3 union elements], /) -> None) | None`
- pydantic/fields.py:1154:5: error[invalid-parameter-default] Default value of type `PydanticUndefinedType` is not assignable to annotated parameter type `dict[str, Divergent] | ((dict[str, Divergent], /) -> None) | None`
+ pydantic/fields.py:1154:5: error[invalid-parameter-default] Default value of type `PydanticUndefinedType` is not assignable to annotated parameter type `dict[str, int | float | str | ... omitted 3 union elements] | ((dict[str, int | float | str | ... omitted 3 union elements], /) -> None) | None`
- pydantic/fields.py:1194:5: error[invalid-parameter-default] Default value of type `PydanticUndefinedType` is not assignable to annotated parameter type `dict[str, Divergent] | ((dict[str, Divergent], /) -> None) | None`
+ pydantic/fields.py:1194:5: error[invalid-parameter-default] Default value of type `PydanticUndefinedType` is not assignable to annotated parameter type `dict[str, int | float | str | ... omitted 3 union elements] | ((dict[str, int | float | str | ... omitted 3 union elements], /) -> None) | None`
- pydantic/fields.py:1573:13: error[invalid-argument-type] Argument is incorrect: Expected `dict[str, Divergent] | ((dict[str, Divergent], /) -> None) | None`, found `Top[dict[Unknown, Unknown]] | (((dict[str, Divergent], /) -> None) & ~Top[dict[Unknown, Unknown]]) | None`
+ pydantic/fields.py:1573:13: error[invalid-argument-type] Argument is incorrect: Expected `dict[str, int | float | str | ... omitted 3 union elements] | ((dict[str, int | float | str | ... omitted 3 union elements], /) -> None) | None`, found `Top[dict[Unknown, Unknown]] | (((dict[str, int | float | str | ... omitted 3 union elements], /) -> None) & ~Top[dict[Unknown, Unknown]]) | None`

Expression (https://github.com/cognitedata/Expression)
+ tests/test_compose.py:21:16: error[invalid-assignment] Object of type `(Never, /) -> Never` is not assignable to `(int, /) -> int`
- Found 200 diagnostics
+ Found 201 diagnostics

setuptools (https://github.com/pypa/setuptools)
+ setuptools/_distutils/command/install.py:719:42: error[invalid-argument-type] Argument to function `__new__` is incorrect: Expected `Iterable[Never]`, found `map[str]`
- Found 1139 diagnostics
+ Found 1140 diagnostics

prefect (https://github.com/PrefectHQ/prefect)
- src/prefect/input/run_input.py:672:20: error[invalid-return-type] Return type does not match returned value: expected `T@GetAutomaticInputHandler | AutomaticRunInput[T@GetAutomaticInputHandler]`, found `T@GetAutomaticInputHandler | AutomaticRunInput[T@GetAutomaticInputHandler] | Coroutine[Any, Any, T@GetAutomaticInputHandler | AutomaticRunInput[T@GetAutomaticInputHandler]]`
+ src/prefect/input/run_input.py:672:20: error[invalid-return-type] Return type does not match returned value: expected `T@GetAutomaticInputHandler | AutomaticRunInput[T@GetAutomaticInputHandler]`, found `Unknown | Coroutine[Any, Any, Unknown]`

scikit-build-core (https://github.com/scikit-build/scikit-build-core)
+ src/scikit_build_core/build/wheel.py:99:20: error[no-matching-overload] No overload of bound method `__init__` matches arguments
- Found 49 diagnostics
+ Found 50 diagnostics

sympy (https://github.com/sympy/sympy)
- sympy/algebras/quaternion.py:132:22: error[invalid-assignment] Object of type `Basic` is not assignable to `Expr | int | float | complex`
+ sympy/algebras/quaternion.py:132:22: error[invalid-assignment] Object of type `Basic | int | float | complex | Any` is not assignable to `Expr | int | float | complex`
- sympy/algebras/quaternion.py:132:22: error[invalid-assignment] Object of type `Basic` is not assignable to `Expr | int | float | complex`
+ sympy/algebras/quaternion.py:132:22: error[invalid-assignment] Object of type `Basic | int | float | complex | Any` is not assignable to `Expr | int | float | complex`
- sympy/algebras/quaternion.py:132:22: error[invalid-assignment] Object of type `Basic` is not assignable to `Expr | int | float | complex`
+ sympy/algebras/quaternion.py:132:22: error[invalid-assignment] Object of type `Basic | int | float | complex | Any` is not assignable to `Expr | int | float | complex`
- sympy/algebras/quaternion.py:132:22: error[invalid-assignment] Object of type `Basic` is not assignable to `Expr | int | float | complex`
+ sympy/algebras/quaternion.py:132:22: error[invalid-assignment] Object of type `Basic | int | float | complex | Any` is not assignable to `Expr | int | float | complex`
- sympy/functions/combinatorial/factorials.py:967:13: error[unsupported-operator] Operator `-` is not supported between two objects of type `Basic`
+ sympy/functions/combinatorial/factorials.py:967:13: error[unsupported-operator] Operator `-` is not supported between two objects of type `Basic | int | float | complex | Any`
+ sympy/functions/combinatorial/factorials.py:968:29: warning[possibly-missing-attribute] Attribute `is_nonnegative` may be missing on object of type `Basic | int | float | complex | Any`
+ sympy/functions/combinatorial/factorials.py:968:47: warning[possibly-missing-attribute] Attribute `is_integer` may be missing on object of type `Basic | int | float | complex | Any`
+ sympy/functions/combinatorial/factorials.py:969:12: warning[possibly-missing-attribute] Attribute `is_zero` may be missing on object of type `Basic | int | float | complex | Any`
- sympy/functions/combinatorial/factorials.py:972:13: error[unsupported-operator] Operator `-` is not supported between objects of type `Basic` and `Literal[1]`
+ sympy/functions/combinatorial/factorials.py:972:13: error[unsupported-operator] Operator `-` is not supported between objects of type `Basic | int | float | complex | Any` and `Literal[1]`
+ sympy/functions/combinatorial/factorials.py:975:12: warning[possibly-missing-attribute] Attribute `is_integer` may be missing on object of type `Basic | int | float | complex | Any`
+ sympy/functions/combinatorial/factorials.py:976:16: warning[possibly-missing-attribute] Attribute `is_negative` may be missing on object of type `Basic | int | float | complex | Any`
+ sympy/functions/combinatorial/factorials.py:978:18: warning[possibly-missing-attribute] Attribute `is_number` may be missing on object of type `Basic | int | float | complex | Any`
+ sympy/functions/combinatorial/factorials.py:984:14: warning[possibly-missing-attribute] Attribute `is_number` may be missing on object of type `Basic | int | float | complex | Any`
- sympy/functions/combinatorial/factorials.py:986:26: error[unsupported-operator] Operator `+` is not supported between objects of type `Basic` and `Literal[1]`
+ sympy/functions/combinatorial/factorials.py:986:26: error[unsupported-operator] Operator `+` is not supported between objects of type `Basic | int | float | complex | Any` and `Literal[1]`
- sympy/functions/combinatorial/factorials.py:986:40: error[unsupported-operator] Operator `+` is not supported between objects of type `Basic` and `Literal[1]`
+ sympy/functions/combinatorial/factorials.py:986:40: error[unsupported-operator] Operator `+` is not supported between objects of type `Basic | int | float | complex | Any` and `Literal[1]`
- sympy/functions/combinatorial/factorials.py:986:53: error[unsupported-operator] Operator `-` is not supported between two objects of type `Basic`
+ sympy/functions/combinatorial/factorials.py:986:53: error[unsupported-operator] Operator `-` is not supported between two objects of type `Basic | int | float | complex | Any`
+ sympy/geometry/polygon.py:1500:12: warning[possibly-missing-attribute] Attribute `is_Number` may be missing on object of type `Basic | int | float | complex | Any`
- sympy/geometry/polygon.py:1501:20: error[invalid-argument-type] Argument to function `as_int` is incorrect: Expected `SupportsIndex`, found `Basic`
+ sympy/geometry/polygon.py:1501:20: error[invalid-argument-type] Argument to function `as_int` is incorrect: Expected `SupportsIndex`, found `Basic | int | float | complex | Any`
- sympy/geometry/polygon.py:1502:16: error[unsupported-operator] Operator `<` is not supported between objects of type `Basic` and `Literal[3]`
+ sympy/geometry/polygon.py:1502:16: error[unsupported-operator] Operator `<` is not supported between objects of type `Basic | int | float | complex | Any` and `Literal[3]`
+ sympy/geometry/polygon.py:1509:40: warning[possibly-missing-attribute] Attribute `is_number` may be missing on object of type `Basic | int | float | complex | Any`
+ sympy/parsing/mathematica.py:692:38: error[invalid-argument-type] Argument to function `__new__` is incorrect: Expected `Iterable[Never]`, found `Unknown | list[Unknown | str]`
- sympy/physics/optics/gaussopt.py:263:56: error[unsupported-operator] Operator `/` is not supported between two objects of type `Basic`
+ sympy/physics/optics/gaussopt.py:263:56: error[unsupported-operator] Operator `/` is not supported between two objects of type `Basic | int | float | complex | Any`
- sympy/physics/optics/gaussopt.py:298:54: error[unsupported-operator] Operator `-` is not supported between two objects of type `Basic`
+ sympy/physics/optics/gaussopt.py:298:54: error[unsupported-operator] Operator `-` is not supported between two objects of type `Basic | int | float | complex | Any`
- sympy/physics/optics/gaussopt.py:298:69: error[unsupported-operator] Operator `/` is not supported between two objects of type `Basic`
+ sympy/physics/optics/gaussopt.py:298:69: error[unsupported-operator] Operator `/` is not supported between two objects of type `Basic | int | float | complex | Any`
- sympy/physics/optics/gaussopt.py:707:12: error[unsupported-operator] Operator `**` is not supported between objects of type `Basic` and `Literal[2]`
+ sympy/physics/optics/gaussopt.py:707:12: error[unsupported-operator] Operator `**` is not supported between objects of type `Basic | int | float | complex | Any` and `Literal[2]`
+ sympy/physics/optics/gaussopt.py:756:8: warning[possibly-missing-attribute] Attribute `is_infinite` may be missing on object of type `Basic | int | float | complex | Any`
+ sympy/physics/optics/gaussopt.py:756:25: warning[possibly-missing-attribute] Attribute `is_infinite` may be missing on object of type `Basic | int | float | complex | Any`
+ sympy/physics/optics/gaussopt.py:757:21: warning[possibly-missing-attribute] Attribute `is_infinite` may be missing on object of type `Basic | int | float | complex | Any`
- sympy/physics/optics/gaussopt.py:759:16: error[unsupported-operator] Operator `*` is not supported between two objects of type `Basic`
+ sympy/physics/optics/gaussopt.py:759:16: error[unsupported-operator] Operator `*` is not supported between two objects of type `Basic | int | float | complex | Any`
- sympy/physics/optics/gaussopt.py:759:21: error[unsupported-operator] Operator `+` is not supported between two objects of type `Basic`
+ sympy/physics/optics/gaussopt.py:759:21: error[unsupported-operator] Operator `+` is not supported between two objects of type `Basic | int | float | complex | Any`
- sympy/physics/optics/gaussopt.py:790:34: error[unsupported-operator] Unary operator `-` is not supported for object of type `Basic`
+ sympy/physics/optics/gaussopt.py:790:34: error[unsupported-operator] Unary operator `-` is not supported for object of type `Basic | int | float | complex | Any`
- sympy/physics/optics/gaussopt.py:837:30: error[unsupported-operator] Operator `**` is not supported between objects of type `Basic` and `Literal[2]`
+ sympy/physics/optics/gaussopt.py:837:30: error[unsupported-operator] Operator `**` is not supported between objects of type `Basic | int | float | complex | Any` and `Literal[2]`
- sympy/physics/optics/gaussopt.py:837:41: error[unsupported-operator] Operator `-` is not supported between two objects of type `Basic`
+ sympy/physics/optics/gaussopt.py:837:41: error[unsupported-operator] Operator `-` is not supported between two objects of type `Basic | int | float | complex | Any`
- sympy/physics/optics/gaussopt.py:837:54: error[unsupported-operator] Operator `/` is not supported between objects of type `Literal[1]` and `Basic`
+ sympy/physics/optics/gaussopt.py:837:54: error[unsupported-operator] Operator `/` is not supported between objects of type `Literal[1]` and `Basic | int | float | complex | Any`
- sympy/physics/optics/gaussopt.py:838:22: error[unsupported-operator] Operator `/` is not supported between two objects of type `Basic`
+ sympy/physics/optics/gaussopt.py:838:22: error[unsupported-operator] Operator `/` is not supported between two objects of type `Basic | int | float | complex | Any`
- sympy/physics/optics/gaussopt.py:838:37: error[unsupported-operator] Operator `/` is not supported between two objects of type `Basic`
+ sympy/physics/optics/gaussopt.py:838:37: error[unsupported-operator] Operator `/` is not supported between two objects of type `Basic | int | float | complex | Any`
- sympy/physics/optics/gaussopt.py:839:31: error[unsupported-operator] Operator `/` is not supported between two objects of type `Basic`
+ sympy/physics/optics/gaussopt.py:839:31: error[unsupported-operator] Operator `/` is not supported between two objects of type `Basic | int | float | complex | Any`
- sympy/physics/optics/gaussopt.py:839:46: error[unsupported-operator] Operator `/` is not supported between two objects of type `Basic`
+ sympy/physics/optics/gaussopt.py:839:46: error[unsupported-operator] Operator `/` is not supported between two objects of type `Basic | int | float | complex | Any`
- sympy/physics/optics/gaussopt.py:887:9: error[unsupported-operator] Operator `/` is not supported between two objects of type `Basic`
+ sympy/physics/optics/gaussopt.py:887:9: error[unsupported-operator] Operator `/` is not supported between two objects of type `Basic | int | float | complex | Any`
+ sympy/physics/quantum/cg.py:83:34: error[invalid-argument-type] Argument to function `__new__` is incorrect: Expected `Basic`, found `Basic | int | float | complex | Any`
+ sympy/physics/quantum/cg.py:258:34: error[invalid-argument-type] Argument to function `__new__` is incorrect: Expected `Basic`, found `Basic | int | float | complex | Any`
+ sympy/physics/quantum/cg.py:347:34: error[invalid-argument-type] Argument to function `__new__` is incorrect: Expected `Basic`, found `Basic | int | float | complex | Any`
+ sympy/polys/polytools.py:5997:12: warning[possibly-missing-attribute] Attribute `is_algebraic` may be missing on object of type `Basic | int | float | complex | Any`
+ sympy/polys/polytools.py:5997:31: warning[possibly-missing-attribute] Attribute `is_irrational` may be missing on object of type `Basic | int | float | complex | Any`
+ sympy/polys/polytools.py:5997:51: warning[possibly-missing-attribute] Attribute `is_algebraic` may be missing on object of type `Basic | int | float | complex | Any`
+ sympy/polys/polytools.py:5997:70: warning[possibly-missing-attribute] Attribute `is_irrational` may be missing on object of type `Basic | int | float | complex | Any`
- sympy/polys/polytools.py:5998:20: error[unsupported-operator] Operator `/` is not supported between two objects of type `Basic`
+ sympy/polys/polytools.py:5998:20: error[unsupported-operator] Operator `/` is not supported between two objects of type `Basic | int | float | complex | Any`
+ sympy/polys/polytools.py:6127:12: warning[possibly-missing-attribute] Attribute `is_algebraic` may be missing on object of type `Basic | int | float | complex | Any`
+ sympy/polys/polytools.py:6127:31: warning[possibly-missing-attribute] Attribute `is_irrational` may be missing on object of type `Basic | int | float | complex | Any`
+ sympy/polys/polytools.py:6127:51: warning[possibly-missing-attribute] Attribute `is_algebraic` may be missing on object of type `Basic | int | float | complex | Any`
+ sympy/polys/polytools.py:6127:70: warning[possibly-missing-attribute] Attribute `is_irrational` may be missing on object of type `Basic | int | float | complex | Any`
- sympy/polys/polytools.py:6128:20: error[unsupported-operator] Operator `/` is not supported between two objects of type `Basic`
+ sympy/polys/polytools.py:6128:20: error[unsupported-operator] Operator `/` is not supported between two objects of type `Basic | int | float | complex | Any`
+ sympy/series/formal.py:987:34: error[invalid-argument-type] Argument to function `__new__` is incorrect: Expected `Basic`, found `Basic | int | float | complex | Any`
+ sympy/series/fourier.py:146:34: error[invalid-argument-type] Argument to function `__new__` is incorrect: Expected `Basic`, found `Basic | int | float | complex | Any`
+ sympy/simplify/sqrtdenest.py:430:25: warning[possibly-missing-attribute] Attribute `subs` may be missing on object of type `Basic | int | float | complex | Any`
- sympy/stats/tests/test_finite_rv.py:361:32: error[unsupported-operator] Operator `*` is not supported between two objects of type `Basic`
+ sympy/stats/tests/test_finite_rv.py:361:32: error[unsupported-operator] Operator `*` is not supported between two objects of type `Basic | int | float | complex | Any`
- sympy/stats/tests/test_finite_rv.py:362:20: error[unsupported-operator] Operator `>` is not supported between objects of type `Basic` and `Literal[1]`
+ sympy/stats/tests/test_finite_rv.py:362:20: error[unsupported-operator] Operator `>` is not supported between objects of type `Basic | int | float | complex | Any` and `Literal[1]`
- sympy/stats/tests/test_finite_rv.py:363:46: error[unsupported-operator] Operator `/` is not supported between two objects of type `Basic`
+ sympy/stats/tests/test_finite_rv.py:363:46: error[unsupported-operator] Operator `/` is not supported between two objects of type `Basic | int | float | complex | Any`
- sympy/stats/tests/test_finite_rv.py:363:52: error[unsupported-operator] Operator `-` is not supported between two objects of type `Basic`
+ sympy/stats/tests/test_finite_rv.py:363:52: error[unsupported-operator] Operator `-` is not supported between two objects of type `Basic | int | float | complex | Any`
- sympy/stats/tests/test_finite_rv.py:363:62: error[unsupported-operator] Operator `-` is not supported between two objects of type `Basic`
+ sympy/stats/tests/test_finite_rv.py:363:62: error[unsupported-operator] Operator `-` is not supported between two objects of type `Basic | int | float | complex | Any`
- sympy/stats/tests/test_finite_rv.py:363:70: error[unsupported-operator] Operator `-` is not supported between objects of type `Basic` and `Literal[1]`
+ sympy/stats/tests/test_finite_rv.py:363:70: error[unsupported-operator] Operator `-` is not supported between objects of type `Basic | int | float | complex | Any` and `Literal[1]`
- sympy/stats/tests/test_finite_rv.py:365:20: error[unsupported-operator] Operator `>` is not supported between objects of type `Basic` and `Literal[2]`
+ sympy/stats/tests/test_finite_rv.py:365:20: error[unsupported-operator] Operator `>` is not supported between objects of type `Basic | int | float | complex | Any` and `Literal[2]`
- sympy/stats/tests/test_finite_rv.py:365:30: error[unsupported-operator] Operator `<` is not supported between objects of type `Literal[0]` and `Basic`
+ sympy/stats/tests/test_finite_rv.py:365:30: error[unsupported-operator] Operator `<` is not supported between objects of type `Literal[0]` and `Basic | int | float | complex | Any`
- sympy/stats/tests/test_finite_rv.py:365:34: error[unsupported-operator] Operator `<` is not supported between two objects of type `Basic`
+ sympy/stats/tests/test_finite_rv.py:365:34: error[unsupported-operator] Operator `<` is not supported between two objects of type `Basic | int | float | complex | Any`
- sympy/stats/tests/test_finite_rv.py:365:44: error[unsupported-operator] Operator `<` is not supported between two objects of type `Basic`
+ sympy/stats/tests/test_finite_rv.py:365:44: error[unsupported-operator] Operator `<` is not supported between two objects of type `Basic | int | float | complex | Any`
- sympy/stats/tests/test_finite_rv.py:366:57: error[unsupported-operator] Operator `*` is not supported between objects of type `Literal[2]` and `Basic`
+ sympy/stats/tests/test_finite_rv.py:366:57: error[unsupported-operator] Operator `*` is not supported between objects of type `Literal[2]` and `Basic | int | float | complex | Any`
- sympy/stats/tests/test_finite_rv.py:366:67: error[unsupported-operator] Operator `-` is not supported between objects of type `Basic` and `Literal[1]`
+ sympy/stats/tests/test_finite_rv.py:366:67: error[unsupported-operator] Operator `-` is not supported between objects of type `Basic | int | float | complex | Any` and `Literal[1]`
- sympy/stats/tests/test_finite_rv.py:366:79: error[unsupported-operator] Operator `*` is not supported between objects of type `Literal[2]` and `Basic`
+ sympy/stats/tests/test_finite_rv.py:366:79: error[unsupported-operator] Operator `*` is not supported between objects of type `Literal[2]` and `Basic | int | float | complex | Any`
- sympy/stats/tests/test_finite_rv.py:367:33: error[unsupported-operator] Operator `*` is not supported between two objects of type `Basic`
+ sympy/stats/tests/test_finite_rv.py:367:33: error[unsupported-operator] Operator `*` is not supported between two objects of type `Basic | int | float | complex | Any`
- sympy/stats/tests/test_finite_rv.py:367:38: error[unsupported-operator] Operator `-` is not supported between two objects of type `Basic`
+ sympy/stats/tests/test_finite_rv.py:367:38: error[unsupported-operator] Operator `-` is not supported between two objects of type `Basic | int | float | complex | Any`
- sympy/stats/tests/test_finite_rv.py:367:46: error[unsupported-operator] Operator `-` is not supported between two objects of type `Basic`
+ sympy/stats/tests/test_finite_rv.py:367:46: error[unsupported-operator] Operator `-` is not supported between two objects of type `Basic | int | float | complex | Any`
- sympy/stats/tests/test_finite_rv.py:367:55: error[unsupported-operator] Operator `-` is not supported between objects of type `Basic` and `Literal[2]`
+ sympy/stats/tests/test_finite_rv.py:367:55: error[unsupported-operator] Operator `-` is not supported between objects of type `Basic | int | float | complex | Any` and `Literal[2]`
- Found 16035 diagnostics
+ Found 16062 diagnostics

No memory usage changes detected ✅

Copy link
Contributor

@ntBre ntBre left a comment

Choose a reason for hiding this comment

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

I managed to come up with a few nits, but this looks good to me overall. The main things I'm worried about are the trailing whitespace and the ruff_formatter dependency (sorry again about that one!).


let offset = FIRST_LINE.text_len();
let mut changed = false;
let mut result = String::with_capacity(source.len());
Copy link
Contributor

Choose a reason for hiding this comment

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

We might actually want to skip this with_capacity call since String::new() won't allocate at all in the case that nothing changes and we're able to return None.

Copy link
Member Author

Choose a reason for hiding this comment

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

Should I do the same thing in format_code_blocks above? Is there a way to "initialize with full capacity only once needed"?

Copy link
Contributor

@ntBre ntBre Feb 9, 2026

Choose a reason for hiding this comment

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

It's probably not a big deal either way, but yeah I guess you could do the same in format_code_blocks. I don't think there's a nice way to initialize only if needed. There's reserve, but that's not quite the same.

I think it's fine to leave this as-is.

Comment on lines 159 to 167
while let Some(next_line) = lines.peek() {
if next_line.starts_with(CONTINUATION) {
end = next_line.full_end();
unformatted.push_str(&source[TextRange::new(next_line.start() + offset, end)]);
lines.next();
} else {
break;
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
while let Some(next_line) = lines.peek() {
if next_line.starts_with(CONTINUATION) {
end = next_line.full_end();
unformatted.push_str(&source[TextRange::new(next_line.start() + offset, end)]);
lines.next();
} else {
break;
}
}
while let Some(next_line) = lines.next_if(|line| line.starts_with(CONTINUATION)) {
end = next_line.full_end();
unformatted.push_str(&source[TextRange::new(next_line.start() + offset, end)]);
}

I think you can simplify this slightly with the next_if helper.

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm not sure if I like this as much once I had to add logic to deal with empty continuation lines (ie, no space after the "...") 🤔

What do you think? 257b0ae

Copy link
Contributor

Choose a reason for hiding this comment

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

That commit looks fine to me! What don't you like about it?

Copy link
Member Author

Choose a reason for hiding this comment

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

mostly that it didn't feel "simpler" at this point, but ¯_(ツ)_/¯

@ntBre ntBre added formatter Related to the formatter preview Related to preview mode features labels Feb 6, 2026
@amyreese amyreese merged commit cc988ac into main Feb 9, 2026
42 checks passed
@amyreese amyreese deleted the amy/markdown-pycon-blocks branch February 9, 2026 19:16
carljm added a commit to Hugo-Polloli/ruff that referenced this pull request Feb 9, 2026
* main: (45 commits)
  [ty] Fix wrong inlay hints for overloaded function arguments (astral-sh#23179)
  [ty] Respect `@no_type_check` when combined with other decorators (astral-sh#23177)
  [ty] Use type context when inferring constructor argument types (astral-sh#23139)
  [`airflow`] Add ruff rules to catch deprecated attribute access from context key for Airflow 3.0 (`AIR301`) (astral-sh#22850)
  Support formatting `pycon` markdown code blocks (astral-sh#23112)
  Markdown formatting in LSP (astral-sh#23063)
  Instruct Claude to use comments more sparingly (astral-sh#23181)
  [`flake8-gettext`] Fix false negatives for plural argument of ngettext (`INT001`, `INT002`, `INT003`) (astral-sh#21078)
  [ty] Invoking goto-def on parentheses of a class constructor call takes you too constructor method
  [ty] Make goto definition on class constructor always go to class definition
  [ty] Assign lower completions ranking to deprecated functions and classes (astral-sh#23089)
  [ty] Fix parameter references across files via keyword args (astral-sh#23012)
  [ty] Exclude enclosing class for base completions (astral-sh#23141)
  [`pyupgrade`] Fix syntax error on string with newline escape and comment (`UP037`) (astral-sh#22968)
  [ty] Improve documentation for `expect_single_definition` method (astral-sh#23175)
  [ty] Configure check mode for all projects
  Add `home-assistant` to ecosystem projects (astral-sh#23132)
  Add tabbed shell completion documentation (astral-sh#23169)
  Bump typing conformance-suite pin (astral-sh#23174)
  [ty] Fix invalid diagnostic location for a sub-call to a specialized ParamSpec (astral-sh#23036)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

formatter Related to the formatter preview Related to preview mode features

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support Python console (pycon) markdown code blocks

2 participants