scikit-hep / scikit-hep/vector
Pyright showing errors
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 99
- Forks
- 42
- Avg merge
- 1d 13h
- Merged PRs (30d)
- 6
Description
Vector Version
1.6.3
Python Version
3.12
OS / Environment
Almalinux9 with micromamba environment
Describe the bug
This is the same as:
https://github.com/scikit-hep/vector/issues/611
but I cannot reopen it. I was too busy to get back to it, but it keeps bugging me so I will open this.
The MRW is:
import vector
from vector import MomentumObject4D as v4d
a: v4d = vector.obj(pt=1.0, eta=0.1, phi=0.2, mass=0.5)
b: v4d = vector.obj(pt=2.0, eta=0.2, phi=0.3, mass=0.6)
x = 3
if x == 3:
d = a
else:
d = a - b
c = a + b
d = c + d
with pyright I see:
/home/acampove/Tests/vector/type_error.py:14:5 - error: Operator "+" not supported for types "VectorProtocol" and "MomentumObject4D | VectorProtocol"
Operator "+" not supported for types "VectorProtocol" and "VectorProtocol" (reportOperatorIssue)
1 error, 0 warnings, 0 informations
with mypy I see:
type_error.py:11: error: Incompatible types in assignment (expression has type "VectorProtocol", variable has type "MomentumObject4D") [assignment]
type_error.py:14: error: Incompatible types in assignment (expression has type "VectorProtocol", variable has type "MomentumObject4D") [assignment]
Found 2 errors in 1 file (checked 1 source file)
so, the problem is even worse with mypy.
Any additional but relevant log output
No response
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 minimal reproducer in type_error.py and compare its Pyright and mypy results for the Vector type annotations shown. Read the related issue 611 for prior context, then trace the annotations involved in vector.obj and vector arithmetic. Done means the reproducer no longer reports the incompatible operator and assignment errors under the relevant type checkers.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100