microsoft / microsoft/pyright

Type Annotation are not allowed for enum members when using nonmember

Open
#10,941 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Python
Stars
15.6k
Forks
1.8k
Avg merge
12h 13m
Merged PRs (30d)
52

Description

Note: if you are reporting a wrong signature of a function or a class in the standard library, then the typeshed tracker is better suited for this report: https://github.com/python/typeshed/issues.

If you have a question about typing or a behavior that you’re seeing in Pyright (as opposed to a bug report or enhancement request), consider posting to the Pyright discussion forum.

Describe the bug
Type annotations are not allowed for enum members when trying to use a nonmember()

I tried to follow the example here, but I am new to using nonmember, so I could be doing something wrong.
https://github.com/microsoft/pyright/issues/7265

Code or Screenshots
If possible, provide a minimal, self-contained code sample (surrounded by triple back ticks) to demonstrate the issue. The code should define or import all referenced symbols.

from enum import IntEnum, nonmember

class BaseIntEnum(IntEnum):
    _db_table: str | None = nonmember(None)
    _db_id_column = nonmember(None)
    _db_name_column = nonmember(None)

If your code relies on symbols that are imported from a third-party library, include the associated import statements and specify which versions of those libraries you have installed.

VS Code extension or command-line
Are you running pyright as a VS Code extension, a language server in another editor, integrated into Pylance, or the command-line tool? Which version?

Using in Zed editor, but to test I used pyright-play.net

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the minimal IntEnum example in the issue and run it in pyright-play.net to reproduce the diagnostic. Investigate how Pyright handles annotated enum members assigned with nonmember(); done means the behavior is clarified and covered by a regression check showing the intended diagnostic outcome.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.