Skip to content

typ: define stub type aliases after the classes they reference - #433

Merged
oscarbenjamin merged 3 commits into
flintlib:mainfrom
ilgrad:fix/stub-alias-forward-refs
Oct 13, 2026
Merged

oscarbenjamin merged 3 commits into
flintlib:mainfrom
ilgrad:fix/stub-alias-forward-refs

Conversation

@ilgrad

@ilgrad ilgrad commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

The input type aliases in the stubs (iarb, iacb, ifmpz, ...) were assigned above the classes they name, e.g. iarb = ... | arb above class arb. ty resolves such a forward reference to Unknown, so under ty arb(2) * acb(1) was inferred as arb. This defines each alias after its class; mypy and pyright see no change.

It also removes the unused cdef ulong w in fmpz.pxd that cython-lint 0.22 reports, which made the Lint job fail (moved here from #434).

The input type aliases in the stubs (iarb, iacb, ifmpz, ...) were
assigned above the class they name, e.g. `iarb = ... | arb` above
`class arb`. ty resolves a forward reference in the value of a plain
assignment to Unknown, even in a stub, so every parameter annotated
with one of these aliases was Unknown under ty: `arb(2) * acb(1)` was
inferred as `arb` and `iarb` accepted an `acb`. Defining each alias
after the class it references fixes this. mypy and pyright output is
unchanged.
@ilgrad

ilgrad commented Oct 13, 2026

Copy link
Copy Markdown
Contributor Author

The three red jobs are not caused by this PR:

  • Lint (3.12): cython-lint 0.22.0 (released 2026-10-07) reports fmpz.pxd:25:16: 'w' defined but unused on main too. Remove unused variable flagged by cython-lint 0.22 #434 removes that variable.
  • Build Windows arm64 wheels: Chocolatey returned 504 Gateway Timeout for pkgconfiglite, so pkg-config was not installed and meson could not find GMP.
  • Test 3.14t wheel on windows-11-arm: this job failed because the arm64 wheel build failed. It then tried to build the sdist offline and could not get meson-python.

Re-running the Windows arm64 jobs should clear the last two failures.

@oscarbenjamin

Copy link
Copy Markdown
Collaborator

Please don't paste the excessively long LLM-generated explanation in the PR description. The reason for this can be explained in just a few human-written sentences.

cython-lint 0.22.0 now reports unused cdef locals in inline functions
defined in .pxd files, so the Lint job fails on main with
fmpz.pxd:25:16: 'w' defined but unused. The variable has been unused
since the from_bytes/to_bytes conversion rewrite (f349183).
@ilgrad

ilgrad commented Oct 13, 2026

Copy link
Copy Markdown
Contributor Author

Sorry about that. I've shortened the description and added the fmpz.pxd change from #434 here.

@oscarbenjamin

Copy link
Copy Markdown
Collaborator

Okay, looks good. Thanks.

@oscarbenjamin
oscarbenjamin merged commit a6f1b58 into flintlib:main Oct 13, 2026
103 checks passed
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