Skip to content

Returning Unknown instead of Any for incomplete __getattr__ #13765

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

Open
Avasam opened this issue Apr 2, 2025 · 1 comment
Open

Returning Unknown instead of Any for incomplete __getattr__ #13765

Avasam opened this issue Apr 2, 2025 · 1 comment
Labels
stubs: false negative Type checkers do not report an error, but should

Comments

@Avasam
Copy link
Collaborator

Avasam commented Apr 2, 2025

I noticed we have quite a few

def __getattr__(name: str) -> Incomplete: ...

Wouldn't it be better to write as

def __getattr__(name: str): ...  # incomplete

So that type-checkers like Pyright in strict mode can warn about unknown types ?

@Avasam Avasam added the stubs: false negative Type checkers do not report an error, but should label Apr 2, 2025
@srittau
Copy link
Collaborator

srittau commented Apr 2, 2025

I think that was a pattern mandated in CONTRIBUTING for incomplete stubs. I think the current pattern just happened via the route

  1. -> Any: ... # incomplete
  2. -> Incomplete: ... # incomplete
  3. -> Incomplete: ...

That said, I don't have a strong preference either way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stubs: false negative Type checkers do not report an error, but should
Projects
None yet
Development

No branches or pull requests

2 participants