reportOptionalMemberAccess after raise ValueError
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 15.6k
- Forks
- 1.8k
- Avg merge
- 12h 13m
- Merged PRs (30d)
- 52
Description
**Describe the bug**
After checking variable for none value with valueerror raise pylance says about possible none value
**Code or Screenshots**
```python
# Tag is html tag of bs4
# a is value Optional[Tag] (Tag | None)
if a is None:
raise ValueError("...")
b = a.text # here error, pylance says that .text is not attr of None
```
**VS Code extension or command-line**
vscode; pylance 2025.16.0
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the provided minimal Python example in the Pylance VS Code extension and reproduce the diagnostic with pylance 2025.16.0. Investigate how the checker handles narrowing after raising ValueError; done means the diagnostic is no longer reported for a.text after the None check, with regression coverage for this example.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, vscode
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100