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 and type hints #172

Open
mafrosis opened this issue Dec 11, 2022 · 1 comment
Open

Mypy and type hints #172

mafrosis opened this issue Dec 11, 2022 · 1 comment
Labels
enhancement New feature or request

Comments

@mafrosis
Copy link

Hello, great project!

I see most of the code has type hints, but I didn't obviously see mypy in play for type checking?

Adding a py.typed would be most welcome for other projects using mypy.

11: error: Skipping analyzing "rocketry": module is installed, but missing library stubs or py.typed marker  [import]
11: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-import

Further, I ran the stubgen tool locally to generate rocketry stubs for my project, but these stubs appear broken and generate all kinds of errors under mypy.

/mypy-stubs/rocketry/core/parameters/arguments.pyi:8: error: Name "rocketry.Session" is not defined  [name-defined]
/mypy-stubs/rocketry/_base.pyi:1: error: Module "rocketry" has no attribute "Session"; maybe "session"?  [attr-defined]
/mypy-stubs/rocketry/core/parameters/parameters.pyi:10: error: Name "rocketry.Session" is not defined  [name-defined]
/mypy-stubs/rocketry/core/condition/base.pyi:55: error: Signature of "get_state" incompatible with supertype "BaseCondition"  [override]
/mypy-stubs/rocketry/core/condition/base.pyi:55: note:      Superclass:
/mypy-stubs/rocketry/core/condition/base.pyi:55: note:          def get_state(self) -> Any
/mypy-stubs/rocketry/core/condition/base.pyi:55: note:      Subclass:
/mypy-stubs/rocketry/core/condition/base.pyi:55: note:          def get_state(self, res: int) -> Any
/mypy-stubs/rocketry/core/log/adapter.pyi:2: error: Skipping analyzing "redbird": module is installed, but missing library stubs or py.typed marker  [import]
/mypy-stubs/rocketry/core/task.pyi:10: error: Module "rocketry" has no attribute "Session"; maybe "session"?  [attr-defined]
/mypy-stubs/rocketry/core/schedule.pyi:2: error: Module "rocketry" has no attribute "Session"; maybe "session"?  [attr-defined]
/mypy-stubs/rocketry/session.pyi:9: error: Module "rocketry.parse" has no attribute "StaticParser"  [attr-defined]
/mypy-stubs/rocketry/time/delta.pyi:10: error: Incompatible types in assignment (expression has type "Union[datetime, Callable[..., Any]]", base class "TimeDelta" defined the type as "Optional[datetime]")  [assignment]
/mypy-stubs/rocketry/time/interval.pyi:44: error: Signature of "anchor_int" incompatible with supertype "AnchoredInterval"  [override]
/mypy-stubs/rocketry/time/interval.pyi:44: note:      Superclass:
/mypy-stubs/rocketry/time/interval.pyi:44: note:          def anchor_int(self, i: Any, side: Optional[Any] = ..., time_point: Optional[Any] = ..., **kwargs: Any) -> Any
/mypy-stubs/rocketry/time/interval.pyi:44: note:      Subclass:
/mypy-stubs/rocketry/time/interval.pyi:44: note:          def anchor_int(self, i: Any, side: Optional[Any] = ..., **kwargs: Any) -> Any
/mypy-stubs/rocketry/time/interval.pyi:53: error: Return type "None" of "rollforward" incompatible with return type "datetime" in supertype "TimeInterval"  [override]
/mypy-stubs/rocketry/conditions/meta.pyi:2: error: Module "rocketry" has no attribute "Session"; maybe "session"?  [attr-defined]
/mypy-stubs/rocketry/application.pyi:2: error: Skipping analyzing "redbird": module is installed, but missing library stubs or py.typed marker  [import]
/mypy-stubs/rocketry/application.pyi:2: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports
/mypy-stubs/rocketry/application.pyi:3: error: Module "rocketry" has no attribute "Session"; maybe "session"?  [attr-defined]
/mypy-stubs/rocketry/__init__.pyi:8: error: Name "version" already defined (possibly by an import)  [no-redef]
/mypy-stubs/rocketry/__init__.pyi:10: error: Name "version_tuple" already defined (possibly by an import)  [no-redef]
/mypy-stubs/rocketry/tasks/maintain/os.pyi:5: error: Incompatible types in assignment (expression has type "str", base class "Task" defined the type as "Optional[Literal['main', 'async', 'thread', 'process']]")  [assignment]
/mypy-stubs/rocketry/tasks/maintain/os.pyi:11: error: Incompatible types in assignment (expression has type "str", base class "Task" defined the type as "Optional[Literal['main', 'async', 'thread', 'process']]")  [assignment]
Found 29 errors in 15 files (checked 10 source files)
@mafrosis mafrosis added the enhancement New feature or request label Dec 11, 2022
@djnnvx
Copy link
Contributor

djnnvx commented Jan 16, 2023

I'm not too familiar with the stubgen tool but I can look into it when I have the time. Do you have a preferred documentation / tutorial to get into it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants