Skip to content

Pyright showing errors #654

@acampove

Description

@acampove

Vector Version

1.6.3

Python Version

3.12

OS / Environment

Almalinux9 with micromamba environment

Describe the bug

This is the same as:

#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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug (unverified)The problem described would be a bug, but needs to be triaged

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions