Skip to content

typing: complete type annotations in ntheory/partitions_.py#29865

Open
717986230 wants to merge 1 commit into
sympy:masterfrom
717986230:typing-ntheory-partitions
Open

typing: complete type annotations in ntheory/partitions_.py#29865
717986230 wants to merge 1 commit into
sympy:masterfrom
717986230:typing-ntheory-partitions

Conversation

@717986230

Copy link
Copy Markdown

References to other Issues or PRs

Issue: #28806

Brief description of what is fixed or changed

Adds the missing type annotations in sympy/ntheory/partitions_.py:

  • _pre() -> None, with module-level declarations _factor: list[int] and _totient: list[int] (annotation only, so the '_factor' not in globals() check in _partition keeps working)
  • _a(n: int, k: int, prec: int) -> MPF_TUP
  • _d(n: int, j: int, prec: int, sq23pi: MPF_TUP, sqrt8: MPF_TUP) -> MPF_TUP; the local rebinding j = from_int(j) was renamed to jm so the parameter keeps a single type
  • _partition_rec: prev: list[int]
  • inner _M(n: int, N: int) -> float
  • npartitions(n: int, verbose: bool = False) -> Integer

MPF_TUP is the existing alias from sympy.core.evalf (raw mpmath mpf tuple), imported under TYPE_CHECKING.

Verified locally: mypy sympy reports no new errors (only the 2 pre-existing no-redef errors in sympy/__init__.py, also present on master), pytest sympy/ntheory/tests/test_partitions.py passes, and _partition(100) == 190569292.

Other comments

Typing-only change, no behavior change intended.

AI Generation Disclosure

This PR (code and description) was prepared with Claude Code (Anthropic), operated by me. All changed lines in sympy/ntheory/partitions_.py were AI-generated and then verified locally with mypy and the test suite as described above.

NO ENTRY

@sympy-bot

Copy link
Copy Markdown

Hi, I am the SymPy bot. I'm here to help you write a release notes entry. Please read the guide on how to write release notes.

  • No release notes entry will be added for this pull request.
Click here to see the pull request description that was parsed.
#### References to other Issues or PRs

Issue: https://github.com/sympy/sympy/issues/28806

#### Brief description of what is fixed or changed

Adds the missing type annotations in `sympy/ntheory/partitions_.py`:

- `_pre() -> None`, with module-level declarations `_factor: list[int]` and `_totient: list[int]` (annotation only, so the `'_factor' not in globals()` check in `_partition` keeps working)
- `_a(n: int, k: int, prec: int) -> MPF_TUP`
- `_d(n: int, j: int, prec: int, sq23pi: MPF_TUP, sqrt8: MPF_TUP) -> MPF_TUP`; the local rebinding `j = from_int(j)` was renamed to `jm` so the parameter keeps a single type
- `_partition_rec`: `prev: list[int]`
- inner `_M(n: int, N: int) -> float`
- `npartitions(n: int, verbose: bool = False) -> Integer`

`MPF_TUP` is the existing alias from `sympy.core.evalf` (raw mpmath mpf tuple), imported under `TYPE_CHECKING`.

Verified locally: `mypy sympy` reports no new errors (only the 2 pre-existing `no-redef` errors in `sympy/__init__.py`, also present on master), `pytest sympy/ntheory/tests/test_partitions.py` passes, and `_partition(100) == 190569292`.

#### Other comments

Typing-only change, no behavior change intended.

#### AI Generation Disclosure

This PR (code and description) was prepared with Claude Code (Anthropic), operated by me. All changed lines in `sympy/ntheory/partitions_.py` were AI-generated and then verified locally with mypy and the test suite as described above.

<!-- BEGIN RELEASE NOTES -->
NO ENTRY
<!-- END RELEASE NOTES -->

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants