Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1.1.384 forbids ellipsis defaults in NamedTuple stubs #9191

Closed
srittau opened this issue Oct 10, 2024 · 4 comments
Closed

1.1.384 forbids ellipsis defaults in NamedTuple stubs #9191

srittau opened this issue Oct 10, 2024 · 4 comments
Labels
addressed in next version Issue is fixed and will appear in next published version bug Something isn't working regression

Comments

@srittau
Copy link

srittau commented Oct 10, 2024

Describe the bug

Cf. python/typeshed#12764. When trying to update pyright from 1.1.383 to 1.1.384 in typeshed, it reports NamedTuples that use ellipses as defaults:

class ToCPlaceholder(NamedTuple):
    render_function: Callable[[FPDF, Any], object]
    start_page: int
    y: int
    pages: int = ...

Causes:

/home/runner/work/typeshed/typeshed/stubs/fpdf2/fpdf/fpdf.pyi
/home/runner/work/typeshed/typeshed/stubs/fpdf2/fpdf/fpdf.pyi:97:18 - error: Type "EllipsisType" is not assignable to declared type "int"
"EllipsisType" is not assignable to "int" (reportAssignmentType)

Similar to function defaults, NamedTuples can have complex defaults that can't be represented statically in stubs and should use an ellipsis instead.

In [1]: from typing import NamedTuple
In [2]: x = 42
In [3]: class Foo(NamedTuple):
   ...:     a: int
   ...:     b: int = x
   ...: 
In [4]: Foo(12)
Out[4]: Foo(a=12, b=42)
@srittau srittau added the bug Something isn't working label Oct 10, 2024
@srittau
Copy link
Author

srittau commented Oct 10, 2024

This is #9189.

@srittau srittau closed this as not planned Won't fix, can't repro, duplicate, stale Oct 10, 2024
@srittau
Copy link
Author

srittau commented Oct 10, 2024

It actually isn't #9189, that is a separate issue. Please reopen, sorry for the churn.

@erictraut erictraut reopened this Oct 10, 2024
erictraut added a commit that referenced this issue Oct 11, 2024
…es `...` as a default value in a stub file. This addresses #9191.
erictraut added a commit that referenced this issue Oct 11, 2024
…es `...` as a default value in a stub file. This addresses #9191. (#9212)
@erictraut
Copy link
Collaborator

Thanks for the bug report and apologies for the regression. This issue was specific to stubs, so it wasn't covered by pyright's unit tests.

This will be addressed in the next release.

@erictraut erictraut added the addressed in next version Issue is fixed and will appear in next published version label Oct 11, 2024
@erictraut
Copy link
Collaborator

This is addressed in pyright 1.1.385.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
addressed in next version Issue is fixed and will appear in next published version bug Something isn't working regression
Projects
None yet
Development

No branches or pull requests

2 participants