Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mypy errors with user-defined parameter class #3334

Open
starhel opened this issue Jan 17, 2025 · 0 comments
Open

Mypy errors with user-defined parameter class #3334

starhel opened this issue Jan 17, 2025 · 0 comments

Comments

@starhel
Copy link
Contributor

starhel commented Jan 17, 2025

Description
The mypy plugin does not work with parameter classes that are user-defined rather than built into luigi. For example:

import luigi
from uuid import UUID


class UUIDParameter(luigi.Parameter):
    def parse(self, s):
        return UUID(s)


class DummyTask(luigi.Task):
    x: int = luigi.IntParameter()
    y: UUID = UUIDParameter()


dummy_task = DummyTask(x=10, y="9b0591d7-a167-4978-bc6d-41f7d84a288c")
reveal_type(dummy_task.x)
reveal_type(dummy_task.y)
main.py:12: error: Incompatible types in assignment (expression has type "UUIDParameter", variable has type "UUID")  [assignment]
main.py:15: error: Unexpected keyword argument "y" for "DummyTask"  [call-arg]
main.py:16: note: Revealed type is "builtins.int"
main.py:17: note: Revealed type is "uuid.UUID"

Revealed types are correct, but mypy gives 2 errors connected with custom parameter class.

Packages

lockfile==0.12.2
luigi==3.6.0
mypy==1.14.1
mypy-extensions==1.0.0
python-daemon==3.1.2
python-dateutil==2.9.0.post0
six==1.17.0
tenacity==8.5.0
tomli==2.2.1
tornado==6.4.2
typing_extensions==4.12.2
starhel added a commit to starhel/luigi that referenced this issue Jan 17, 2025
starhel added a commit to starhel/luigi that referenced this issue Jan 17, 2025
starhel added a commit to starhel/luigi that referenced this issue Jan 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant