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

[feature] Add Mypy type checking #512

Open
jan-janssen opened this issue Nov 30, 2024 · 0 comments
Open

[feature] Add Mypy type checking #512

jan-janssen opened this issue Nov 30, 2024 · 0 comments

Comments

@jan-janssen
Copy link
Member

List of current issues:

executorlib/standalone/interactive/spawner.py:72: error: Argument "cwd" to "__init__" of "BaseSpawner" has incompatible type "str | None"; expected "str"  [arg-type]
executorlib/standalone/interactive/spawner.py:89: error: Incompatible types in assignment (expression has type "Popen[bytes]", variable has type "None")  [assignment]
executorlib/standalone/interactive/spawner.py:114: error: "None" has no attribute "communicate"  [attr-defined]
executorlib/standalone/interactive/spawner.py:115: error: "None" has no attribute "terminate"  [attr-defined]
executorlib/standalone/interactive/spawner.py:117: error: "None" has no attribute "wait"  [attr-defined]
executorlib/interactive/flux.py:36: error: Argument "cwd" to "__init__" of "BaseSpawner" has incompatible type "str | None"; expected "str"  [arg-type]
executorlib/interactive/flux.py:98: error: "None" has no attribute "cancel"  [attr-defined]
executorlib/interactive/flux.py:102: error: "None" has no attribute "result"  [attr-defined]
executorlib/standalone/serialize.py:32: error: Function "builtins.callable" is not valid as a type  [valid-type]
executorlib/standalone/serialize.py:32: note: Perhaps you meant "typing.Callable" instead of "callable"?
executorlib/standalone/serialize.py:59: error: callable? has no attribute "__name__"  [attr-defined]
executorlib/standalone/interactive/backend.py:6: error: Function "builtins.callable" is not valid as a type  [valid-type]
executorlib/standalone/interactive/backend.py:6: note: Perhaps you meant "typing.Callable" instead of "callable"?
executorlib/standalone/interactive/backend.py:7: error: Function "builtins.callable" is not valid as a type  [valid-type]
executorlib/standalone/interactive/backend.py:7: note: Perhaps you meant "typing.Callable" instead of "callable"?
executorlib/standalone/__init__.py:12: error: Type of __all__ must be "Sequence[str]", not "list[object]"  [misc]
executorlib/backend/interactive_parallel.py:27: error: Accessing "__init__" on an instance is unsound, since instance.__init__ could be from an incompatible subclass  [misc]
executorlib/backend/interactive_parallel.py:54: error: Argument "socket" to "interface_receive" has incompatible type "Socket[Any] | None"; expected "Socket[Any]"  [arg-type]
executorlib/backend/interactive_parallel.py:60: error: Item "None" of "dict[Any, Any] | None" has no attribute "keys"  [union-attr]
executorlib/backend/interactive_parallel.py:60: error: Value of type "dict[Any, Any] | None" is not indexable  [index]
executorlib/backend/interactive_parallel.py:62: error: Argument "socket" to "interface_send" has incompatible type "Socket[Any] | None"; expected "Socket[Any]"  [arg-type]
executorlib/backend/interactive_parallel.py:63: error: Argument "socket" to "interface_shutdown" has incompatible type "Socket[Any] | None"; expected "Socket[Any]"  [arg-type]
executorlib/backend/interactive_parallel.py:63: error: Argument "context" to "interface_shutdown" has incompatible type "Context[Any] | None"; expected "Context[Any]"  [arg-type]
executorlib/backend/interactive_parallel.py:67: error: Item "None" of "dict[Any, Any] | None" has no attribute "keys"  [union-attr]
executorlib/backend/interactive_parallel.py:68: error: Item "None" of "dict[Any, Any] | None" has no attribute "keys"  [union-attr]
executorlib/backend/interactive_parallel.py:69: error: Item "None" of "dict[Any, Any] | None" has no attribute "keys"  [union-attr]
executorlib/backend/interactive_parallel.py:70: error: Item "None" of "dict[Any, Any] | None" has no attribute "keys"  [union-attr]
executorlib/backend/interactive_parallel.py:74: error: Argument "input_dict" to "call_funct" has incompatible type "dict[Any, Any] | None"; expected "dict[Any, Any]"  [arg-type]
executorlib/backend/interactive_parallel.py:82: error: Argument "socket" to "interface_send" has incompatible type "Socket[Any] | None"; expected "Socket[Any]"  [arg-type]
executorlib/backend/interactive_parallel.py:88: error: Argument "socket" to "interface_send" has incompatible type "Socket[Any] | None"; expected "Socket[Any]"  [arg-type]
executorlib/backend/interactive_parallel.py:90: error: Item "None" of "dict[Any, Any] | None" has no attribute "keys"  [union-attr]
executorlib/backend/interactive_parallel.py:91: error: Value of type "dict[Any, Any] | None" is not indexable  [index]
executorlib/backend/interactive_parallel.py:92: error: Item "None" of "dict[Any, Any] | None" has no attribute "keys"  [union-attr]
executorlib/backend/interactive_parallel.py:93: error: Item "None" of "dict[Any, Any] | None" has no attribute "keys"  [union-attr]
executorlib/backend/interactive_parallel.py:95: error: Argument "input_dict" to "call_funct" has incompatible type "dict[Any, Any] | None"; expected "dict[Any, Any]"  [arg-type]
executorlib/standalone/inputcheck.py:111: error: Unsupported operand types for + ("str" and "None")  [operator]
executorlib/standalone/inputcheck.py:111: note: Right operand is of type "str | None"
executorlib/standalone/inputcheck.py:177: error: Unsupported operand types for / ("int" and "None")  [operator]
executorlib/standalone/inputcheck.py:177: note: Right operand is of type "int | None"
executorlib/standalone/inputcheck.py:178: error: Incompatible return value type (got "int | None", expected "int")  [return-value]
executorlib/cache/subprocess_spawner.py:36: error: Argument "file_name" to "check_file_exists" has incompatible type "str | None"; expected "str"  [arg-type]
executorlib/base/executor.py:48: error: "RaisingThread" has no attribute "_kwargs"  [attr-defined]
executorlib/base/executor.py:65: error: Signature of "submit" incompatible with supertype "Executor"  [override]
executorlib/base/executor.py:65: note:      Superclass:
executorlib/base/executor.py:65: note:          def [_P`-1, _T] submit(self, Callable[_P, _T], /, *args: _P.args, **kwargs: _P.kwargs) -> Future[_T]
executorlib/base/executor.py:65: note:      Subclass:
executorlib/base/executor.py:65: note:          def submit(self, fn: callable?, *args: Any, resource_dict: dict[Any, Any] = ..., **kwargs: Any) -> Future[Any]
executorlib/base/executor.py:65: error: Function "builtins.callable" is not valid as a type  [valid-type]
executorlib/base/executor.py:65: note: Perhaps you meant "typing.Callable" instead of "callable"?
executorlib/base/executor.py:100: error: Need type annotation for "f"  [var-annotated]
executorlib/base/executor.py:135: error: Incompatible types in assignment (expression has type "None", variable has type "Queue[Any]")  [assignment]
executorlib/interactive/shared.py:25: error: Signature of "submit" incompatible with supertype "Executor"  [override]
executorlib/interactive/shared.py:25: note:      Superclass:
executorlib/interactive/shared.py:25: note:          def [_P`-1, _T] submit(self, Callable[_P, _T], /, *args: _P.args, **kwargs: _P.kwargs) -> Future[_T]
executorlib/interactive/shared.py:25: note:      Subclass:
executorlib/interactive/shared.py:25: note:          def submit(self, fn: callable?, *args: Any, resource_dict: dict[Any, Any] = ..., **kwargs: Any) -> Future[Any]
executorlib/interactive/shared.py:25: error: Function "builtins.callable" is not valid as a type  [valid-type]
executorlib/interactive/shared.py:25: note: Perhaps you meant "typing.Callable" instead of "callable"?
executorlib/interactive/shared.py:52: error: Need type annotation for "f"  [var-annotated]
executorlib/interactive/shared.py:73: error: Argument 1 to "len" has incompatible type "RaisingThread"; expected "Sized"  [arg-type]
executorlib/interactive/shared.py:76: error: "RaisingThread" has no attribute "__iter__" (not iterable)  [attr-defined]
executorlib/interactive/shared.py:80: error: Incompatible types in assignment (expression has type "None", variable has type "Queue[Any]")  [assignment]
executorlib/interactive/shared.py:82: error: Argument 1 of "_set_process" is incompatible with supertype "ExecutorBase"; supertype defines the argument type as "RaisingThread"  [override]
executorlib/interactive/shared.py:82: note: This violates the Liskov substitution principle
executorlib/interactive/shared.py:82: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#incompatible-overrides
executorlib/interactive/shared.py:89: error: Incompatible types in assignment (expression has type "list[RaisingThread]", variable has type "RaisingThread | None")  [assignment]
executorlib/interactive/shared.py:90: error: Item "RaisingThread" of "RaisingThread | None" has no attribute "__iter__" (not iterable)  [union-attr]
executorlib/interactive/shared.py:90: error: Item "None" of "RaisingThread | None" has no attribute "__iter__" (not iterable)  [union-attr]
executorlib/interactive/shared.py:91: error: "list[RaisingThread]" has no attribute "start"  [attr-defined]
executorlib/interactive/shared.py:132: error: Incompatible default for argument "spawner" (default has type "type[MpiExecSpawner]", argument has type "BaseSpawner")  [assignment]
executorlib/interactive/shared.py:185: error: Incompatible default for argument "spawner" (default has type "type[MpiExecSpawner]", argument has type "BaseSpawner")  [assignment]
executorlib/interactive/shared.py:203: error: Incompatible default for argument "spawner" (default has type "type[MpiExecSpawner]", argument has type "BaseSpawner")  [assignment]
executorlib/interactive/shared.py:230: error: "BaseSpawner" not callable  [operator]
executorlib/interactive/shared.py:260: error: Incompatible default for argument "spawner" (default has type "type[MpiExecSpawner]", argument has type "BaseSpawner")  [assignment]
executorlib/interactive/shared.py:284: error: Need type annotation for "active_task_dict" (hint: "active_task_dict: dict[<type>, <type>] = ...")  [var-annotated]
executorlib/interactive/shared.py:285: error: Need type annotation for "process_lst" (hint: "process_lst: list[<type>] = ...")  [var-annotated]
executorlib/interactive/shared.py:297: error: Need type annotation for "qtask"  [var-annotated]
executorlib/interactive/shared.py:475: error: Incompatible types in assignment (expression has type "list[Any]", variable has type "tuple[Any, ...]")  [assignment]
executorlib/interactive/shared.py:642: error: Incompatible types in assignment (expression has type "object", variable has type "dict[Any, Any]")  [assignment]
executorlib/cache/shared.py:34: error: Incompatible return value type (got "object", expected "str")  [return-value]
executorlib/cache/shared.py:52: error: Function "builtins.callable" is not valid as a type  [valid-type]
executorlib/cache/shared.py:52: note: Perhaps you meant "typing.Callable" instead of "callable"?
executorlib/cache/shared.py:54: error: Function "builtins.callable" is not valid as a type  [valid-type]
executorlib/cache/shared.py:54: note: Perhaps you meant "typing.Callable" instead of "callable"?
executorlib/cache/shared.py:77: error: Need type annotation for "memory_dict" (hint: "memory_dict: dict[<type>, <type>] = ...")  [var-annotated]
executorlib/cache/shared.py:77: error: Need type annotation for "process_dict" (hint: "process_dict: dict[<type>, <type>] = ...")  [var-annotated]
executorlib/cache/shared.py:77: error: Need type annotation for "file_name_dict" (hint: "file_name_dict: dict[<type>, <type>] = ...")  [var-annotated]
executorlib/cache/shared.py:125: error: callable? not callable  [misc]
executorlib/cache/queue_spawner.py:38: error: Argument "file_name" to "check_file_exists" has incompatible type "str | None"; expected "str"  [arg-type]
executorlib/cache/queue_spawner.py:39: error: Argument "file_name" to "get_queue_id" has incompatible type "str | None"; expected "str"  [arg-type]
executorlib/cache/queue_spawner.py:72: error: Argument "file_name" to "dump" has incompatible type "str | None"; expected "str"  [arg-type]
executorlib/cache/queue_spawner.py:73: error: Incompatible return value type (got "int | None", expected "tuple[int, int]")  [return-value]
executorlib/cache/executor.py:23: error: Incompatible types in assignment (expression has type "Callable[[list[Any], list[Any], str | None, dict[Any, Any] | None, str | None, str | None, str | None], Popen[Any]]", variable has type "Callable[[list[Any], list[int], str | None, dict[Any, Any] | None, str | None, str | None, str | None], tuple[int, int]]")  [assignment]
executorlib/cache/executor.py:31: error: Function "builtins.callable" is not valid as a type  [valid-type]
executorlib/cache/executor.py:31: note: Perhaps you meant "typing.Callable" instead of "callable"?
executorlib/cache/executor.py:32: error: Function "builtins.callable" is not valid as a type  [valid-type]
executorlib/cache/executor.py:32: note: Perhaps you meant "typing.Callable" instead of "callable"?
executorlib/cache/executor.py:61: error: Unsupported left operand type for == (callable?)  [operator]
executorlib/cache/executor.py:94: error: Function "builtins.callable" is not valid as a type  [valid-type]
executorlib/cache/executor.py:94: note: Perhaps you meant "typing.Callable" instead of "callable"?
executorlib/backend/cache_parallel.py:26: error: Accessing "__init__" on an instance is unsound, since instance.__init__ could be from an incompatible subclass  [misc]
executorlib/backend/cache_parallel.py:40: error: Value of type "dict[Any, Any] | None" is not indexable  [index]
executorlib/standalone/plot.py:20: error: Need type annotation for "node_lst" (hint: "node_lst: list[<type>] = ...")  [var-annotated]
executorlib/standalone/plot.py:21: error: Need type annotation for "hash_id_dict" (hint: "hash_id_dict: dict[<type>, <type>] = ...")  [var-annotated]
executorlib/interactive/executor.py:76: error: Need type annotation for "_future_hash_dict" (hint: "_future_hash_dict: dict[<type>, <type>] = ...")  [var-annotated]
executorlib/interactive/executor.py:77: error: Need type annotation for "_task_hash_dict" (hint: "_task_hash_dict: dict[<type>, <type>] = ...")  [var-annotated]
executorlib/interactive/executor.py:80: error: Signature of "submit" incompatible with supertype "Executor"  [override]
executorlib/interactive/executor.py:80: note:      Superclass:
executorlib/interactive/executor.py:80: note:          def [_P`-1, _T] submit(self, Callable[_P, _T], /, *args: _P.args, **kwargs: _P.kwargs) -> Future[_T]
executorlib/interactive/executor.py:80: note:      Subclass:
executorlib/interactive/executor.py:80: note:          def submit(self, fn: Callable[..., Any], *args: Any, resource_dict: dict[str, Any] = ..., **kwargs: Any) -> Future[Any]
executorlib/interactive/executor.py:137: error: Unexpected keyword argument "exc_type" for "__exit__" of "Executor"  [call-arg]
executorlib/interactive/executor.py:159: error: Function "builtins.callable" is not valid as a type  [valid-type]
executorlib/interactive/executor.py:159: note: Perhaps you meant "typing.Callable" instead of "callable"?
/Users/janssen/mambaforge/lib/python3.12/site-packages/mypy/typeshed/stdlib/concurrent/futures/_base.pyi:74: note: "__exit__" of "Executor" defined here
executorlib/interactive/executor.py:137: error: Unexpected keyword argument "exc_val" for "__exit__" of "Executor"  [call-arg]
/Users/janssen/mambaforge/lib/python3.12/site-packages/mypy/typeshed/stdlib/concurrent/futures/_base.pyi:74: note: "__exit__" of "Executor" defined here
executorlib/interactive/executor.py:137: error: Unexpected keyword argument "exc_tb" for "__exit__" of "Executor"  [call-arg]
/Users/janssen/mambaforge/lib/python3.12/site-packages/mypy/typeshed/stdlib/concurrent/futures/_base.pyi:74: note: "__exit__" of "Executor" defined here
executorlib/interactive/executor.py:199: error: Argument "init_function" to "check_init_function" has incompatible type "callable? | None"; expected "Callable[..., Any]"  [arg-type]
executorlib/interactive/executor.py:203: error: Value of type "dict[Any, Any] | None" is not indexable  [index]
executorlib/interactive/executor.py:204: error: Unsupported target for indexed assignment ("dict[Any, Any] | None")  [index]
executorlib/interactive/executor.py:205: error: Unsupported target for indexed assignment ("dict[Any, Any] | None")  [index]
executorlib/interactive/executor.py:207: error: Value of type "dict[Any, Any] | None" is not indexable  [index]
executorlib/interactive/executor.py:209: error: Value of type "dict[Any, Any] | None" is not indexable  [index]
executorlib/interactive/executor.py:211: error: Item "None" of "dict[Any, Any] | None" has no attribute "__delitem__"  [union-attr]
executorlib/interactive/executor.py:212: error: Item "None" of "dict[Any, Any] | None" has no attribute "__delitem__"  [union-attr]
executorlib/interactive/executor.py:213: error: Unsupported target for indexed assignment ("dict[Any, Any] | None")  [index]
executorlib/interactive/executor.py:214: error: Unsupported target for indexed assignment ("dict[Any, Any] | None")  [index]
executorlib/interactive/executor.py:215: error: Unsupported target for indexed assignment ("dict[Any, Any] | None")  [index]
executorlib/interactive/executor.py:217: error: Unsupported target for indexed assignment ("dict[Any, Any] | None")  [index]
executorlib/interactive/executor.py:225: error: Argument "executor_kwargs" to "InteractiveExecutor" has incompatible type "dict[Any, Any] | None"; expected "dict[Any, Any]"  [arg-type]
executorlib/interactive/executor.py:226: error: Argument "spawner" to "InteractiveExecutor" has incompatible type "type[FluxPythonSpawner]"; expected "BaseSpawner"  [arg-type]
executorlib/interactive/executor.py:232: error: Argument "executor_kwargs" to "InteractiveStepExecutor" has incompatible type "dict[Any, Any] | None"; expected "dict[Any, Any]"  [arg-type]
executorlib/interactive/executor.py:233: error: Argument "spawner" to "InteractiveStepExecutor" has incompatible type "type[FluxPythonSpawner]"; expected "BaseSpawner"  [arg-type]
executorlib/interactive/executor.py:239: error: Unsupported target for indexed assignment ("dict[Any, Any] | None")  [index]
executorlib/interactive/executor.py:247: error: Argument "executor_kwargs" to "InteractiveExecutor" has incompatible type "dict[Any, Any] | None"; expected "dict[Any, Any]"  [arg-type]
executorlib/interactive/executor.py:248: error: Argument "spawner" to "InteractiveExecutor" has incompatible type "type[SrunSpawner]"; expected "BaseSpawner"  [arg-type]
executorlib/interactive/executor.py:254: error: Argument "executor_kwargs" to "InteractiveStepExecutor" has incompatible type "dict[Any, Any] | None"; expected "dict[Any, Any]"  [arg-type]
executorlib/interactive/executor.py:255: error: Argument "spawner" to "InteractiveStepExecutor" has incompatible type "type[SrunSpawner]"; expected "BaseSpawner"  [arg-type]
executorlib/interactive/executor.py:260: error: Value of type "dict[Any, Any] | None" is not indexable  [index]
executorlib/interactive/executor.py:262: error: Value of type "dict[Any, Any] | None" is not indexable  [index]
executorlib/interactive/executor.py:264: error: Item "None" of "dict[Any, Any] | None" has no attribute "__delitem__"  [union-attr]
executorlib/interactive/executor.py:265: error: Item "None" of "dict[Any, Any] | None" has no attribute "__delitem__"  [union-attr]
executorlib/interactive/executor.py:266: error: Item "None" of "dict[Any, Any] | None" has no attribute "__delitem__"  [union-attr]
executorlib/interactive/executor.py:268: error: Unsupported target for indexed assignment ("dict[Any, Any] | None")  [index]
executorlib/interactive/executor.py:276: error: Argument "executor_kwargs" to "InteractiveExecutor" has incompatible type "dict[Any, Any] | None"; expected "dict[Any, Any]"  [arg-type]
executorlib/interactive/executor.py:277: error: Argument "spawner" to "InteractiveExecutor" has incompatible type "type[MpiExecSpawner]"; expected "BaseSpawner"  [arg-type]
executorlib/interactive/executor.py:283: error: Argument "executor_kwargs" to "InteractiveStepExecutor" has incompatible type "dict[Any, Any] | None"; expected "dict[Any, Any]"  [arg-type]
executorlib/interactive/executor.py:284: error: Argument "spawner" to "InteractiveStepExecutor" has incompatible type "type[MpiExecSpawner]"; expected "BaseSpawner"  [arg-type]
executorlib/__init__.py:19: error: Need type annotation for "__all__" (hint: "__all__: list[<type>] = ...")  [var-annotated]
executorlib/__init__.py:100: error: Function "builtins.callable" is not valid as a type  [valid-type]
executorlib/__init__.py:100: note: Perhaps you meant "typing.Callable" instead of "callable"?
executorlib/__init__.py:121: error: Function "builtins.callable" is not valid as a type  [valid-type]
executorlib/__init__.py:121: note: Perhaps you meant "typing.Callable" instead of "callable"?
executorlib/__init__.py:172: error: Need type annotation for "default_resource_dict"  [var-annotated]
executorlib/__init__.py:189: error: Argument "max_workers" to "create_file_executor" has incompatible type "int | None"; expected "int"  [arg-type]
executorlib/__init__.py:191: error: Argument "max_cores" to "create_file_executor" has incompatible type "int | None"; expected "int"  [arg-type]
Found 126 errors in 17 files (checked 31 source files)
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