Skip to content

reserved python keywords are used as argument names in python stubs, causing mypy errors #2322

@schenker

Description

@schenker

Description

mypy finds errors in the gtsam's generated .pyi files, because reserved python keywords (e.g. global and lambda) are used as argument names.

I observed the problem in gtsam 4.3a0 and gtsam 4.3a1.

Steps to reproduce

$ cmake .. -DGTSAM_BUILD_PYTHON=1
...
-- Build files have been written to: /home/me/Downloads/gtsam-4.3a1/build
$ make python-install
...
Successfully installed gtsam-4.3a1
[100%] Built target python-install
$ mypy --version
mypy 1.19.1 (compiled: yes)
$ mypy python/gtsam/gtsam/__init__.pyi
python/gtsam/gtsam/__init__.pyi:11941: error: Invalid syntax [syntax]
Found 1 error in 1 file (errors prevented further checking)
$ sed -n 11941p python/gtsam/gtsam/__init__.pyi
def evaluateError(self, global: typing.Annotated[numpy.typing.ArrayLike, numpy.float64, "[3, 1]"], trans: Pose3, local: typing.Annotated[numpy.typing.ArrayLike, numpy.float64, "[3, 1]"]) -> typing.Annotated[numpy.typing.NDArray[numpy.float64], "[m, 1]"]:

Expected behavior

Reserved python keywords should not be used as argument names .pyi files, mypy should not find errors in .pyi files.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugBug report

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions