PyCQA / PyCQA/flake8-pyi

`Y062` doesn't account for nested literals

Open
#485 2 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

type-bug
Dominant language
Python
Stars
83
Forks
22
PR merge metrics
No merged PRs in 30d

Description

According to spec, Literal[X, Y] should be treated as Union[Literal[X], Literal[Y], which means nested Literals should be supported by type checkers.

Hence raising Y062 for cases like Literal[1, Literal[2, 1]] would make sense I believe.

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 by locating the implementation and tests for Y062, then read how the rule processes Literal arguments. Add coverage for nested Literal values such as Literal[1, Literal[2, 1]] and verify that valid nested forms no longer produce Y062 while the rule's existing checks still behave as expected.

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
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.