microsoft / microsoft/pyright

Distinguish between "hard" and "soft" literal types

Open
#10,520 0 comments 5 reactions 0 assignees View on GitHub
enhancement request
Dominant language
Python
Stars
15.6k
Forks
1.8k
Avg merge
12h 13m
Merged PRs (30d)
52

Description

Explore the idea of internally tracking "hard" and "soft" literal types internally and changing inference and constraint solving based on this distinction.

There have been multiple requests for pyright to retain literal types selectively under certain conditions.

Mypy appears to implement a variant of this idea, visible to the user as `Literal[1]?` versus `Literal[1]`.

Contributor guide

Open the contributing guide

Research direction

The issue names no files, tests, or concrete entry points. Start by examining Pyright's literal-type inference and constraint-solving implementation, then compare the proposed hard/soft distinction with mypy's Literal behavior; the work is not complete until the intended inference rules and acceptance tests are defined.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
compilers
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.