Skip to content

Commit

Permalink
Adding pyright and removing mypy (#20)
Browse files Browse the repository at this point in the history
* Add pyright and remove mypy.

* Fix some pyright issues.

* Fix pyright.

* Fix ruff and pyright.

* Fixes.

* Ruff check and format.

* Fixes.

* fix.

* Relock.

* Pyright fixes.

* Other components.

* Undo changes.

* Temporary fix for pyright.

* Update linter and formatter in commit-hooks script to pyright.

---------

Co-authored-by: jzazo <[email protected]>
  • Loading branch information
jzazo and jzazo authored Jan 10, 2024
1 parent b195e2d commit e4c5d8f
Show file tree
Hide file tree
Showing 92 changed files with 838 additions and 1,028 deletions.
4 changes: 2 additions & 2 deletions bin/commit-hooks
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ echo "running ruff linter"
poetry run ruff check src/python --fix
echo "running ruff formatter"
poetry run ruff format src/python
# echo "running mypy"
# poetry run mypy
# echo "running pyright"
# poetry run pyright
2 changes: 1 addition & 1 deletion docs/user_documentation/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ encoded in the *pipeline*.
- **Port**: Input or output of a *node*. *Output ports* are connected into *input ports* forming
a dependency, where the output of a *processor* is given as input to the receiving *processor*.

- **Dependency:** Directed edge from a *node's* output port to another *node's* input port.
- **Dependency:** Directed edge from a *node's* output port to another *node's* input port.
The output of one *processor* feeds into the input of the next *processor*.
During orchestration, outputs are passed as inputs to the depending nodes.

Expand Down
6 changes: 3 additions & 3 deletions docs/user_documentation/tutorial_intermediate.md
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,7 @@ outputs = {
Only `standardization.outputs.Z` is specified in the dependencies list and excluded.
Furthremore, pecifying `Z` output could also have been done more verbosely:
```python
{
{
...,
"Z.train": logistic_regression.outputs.Z.train,
"Z.eval": logistic_regression.outputs.Z.eval
Expand Down Expand Up @@ -644,7 +644,7 @@ Modularity and reusability are two core design principles that we promote when b
The following mechanism can be used to make a pipeline provider available.
Note that this mechanism leverages the OnemlApp concepts explained in `oneml-pipelines`. TODO: need link.

First declare your pipeline provider service.
First declare your pipeline provider service.
Second, add your service to the `OnemlProcessorsRegistryServiceGroups.PIPELINE_PROVIDERS` group.

For example in `example/_app_plugin.py`:
Expand Down Expand Up @@ -698,7 +698,7 @@ Every users will be now able to call the pipeline provider by referring to the i
service id, or even call all pipeline providers after making it available to the service group
(which is used in YAML pipelines for example).

The `oneml.processors.registry.IProvidePipeline` interface to create a pipeline provider is
The `oneml.processors.registry.IProvidePipeline` interface to create a pipeline provider is
defined as follows
```python
from typing import Protocol, TypeVar
Expand Down
87 changes: 31 additions & 56 deletions oneml-adocli/poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

106 changes: 66 additions & 40 deletions oneml-adocli/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ dev = []
[tool.poetry.group.dev.dependencies]
oneml-pipelines = { path = "../oneml-pipelines/", develop = true }
coverage = "*"
mypy = "*"
pyright = "*"
pytest = "*"
pytest-cov = "*"
pytest-nunit = "*"
Expand All @@ -52,62 +52,88 @@ adocli-next = 'oneml.adocli_next._entry_point:main'
requires = ["poetry-core>=1.0.0", "poetry-dynamic-versioning"]
build-backend = "poetry.core.masonry.api"

[tool.mypy]
packages = ["oneml", "oneml_test"]
cache_dir = "../.tmp/oneml-adocli/.mypy_cache"
namespace_packages = true
mypy_path = "src/python/:test/python/"
disallow_untyped_calls = true
disallow_untyped_defs = true
disallow_incomplete_defs = true
check_untyped_defs = true
# Disabling this check, it fails if we subclass untyped classes (luigi.Task)
disallow_subclassing_any = false
warn_no_return = true
strict_optional = true
strict_equality = true
no_implicit_optional = true
disallow_any_generics = true
disallow_any_unimported = true
warn_redundant_casts = true
warn_unused_ignores = true
warn_unused_configs = true
show_traceback = true
show_error_codes = true
show_column_numbers = true
[tool.pyright]
pythonVersion = "3.10"
include = ["src/python", "test/python"]
exclude = ["**/__pycache__"]
deprecateTypingAliases = true
reportPropertyTypeMismatch = true
reportUnusedImport = true
reportUnusedClass = true
reportUnusedVariable = true
reportDuplicateImport = true
reportUntypedFunctionDecorator = true
reportUntypedClassDecorator = true
reportUntypedBaseClass = true
reportUntypedNamedTuple = true
reportConstantRedefinition = true
reportDeprecated = true
reportInconsistentConstructor = true
reportUnknownParameterType = true
reportMissingParameterType = true
reportMissingTypeArgument = true
reportUnnecessaryCast = true
reportUnnecessaryContains = true
reportImplicitStringConcatenation = true
reportInvalidStubStatement = true
reportIncompleteStub = true
reportUnnecessaryTypeIgnoreComment = true
reportMatchNotExhaustive = true
reportShadowedImports = true

reportMissingTypeStubs = false
reportImportCycles = false
reportUnusedFunction = false
reportMissingSuperCall = false
reportPrivateUsage = false
reportUninitializedInstanceVariable = false
reportUnknownArgumentType = false
reportUnknownLambdaType = false
reportUnknownVariableType = false
reportUnknownMemberType = false
reportCallInDefaultInitializer = false
reportUnnecessaryIsInstance = false
reportUnnecessaryComparison = false
reportUnusedCallResult = false
reportUnusedExpression = false
reportImplicitOverride = false
reportIncompatibleVariableOverride = false
reportIncompatibleMethodOverride = false


[tool.ruff]
cache-dir = "../.tmp/oneml-habitats/.ruff_cache"
include = ["src/python", "test/python", "pyproject.toml"]
cache-dir = "../.tmp/oneml-adocli/.ruff_cache"
include = ["src/python/**/*.py", "test/python/**/*.py", "pyproject.toml"]
line-length = 99
indent-width = 4
target-version = "py310"

[tool.ruff.lint]
# Enable Pyflakes (`F`) and a subset of the pycodestyle (`E`) codes by default.
# B026: Star-arg unpacking after a keyword argument is strongly discouraged
# D100: Missing docstring in public module
# D101: Missing docstring in public class
# D102: Missing docstring in public method
# D103: Missing docstring in public function
# D104: Missing docstring in public package
# D105: Missing docstring in magic method
# D107: Missing docstring in __init__
# D417: Missing argument descriptions in Docstrings
# E203: Whitespace before ':'
# E501: Line too long ({width} > {limit})
select = ["B", "D", "E", "F", "I", "Q", "W", "NPY", "PD", "PTH", "RUF", "UP"]
ignore = ["B026", "D100", "D101", "D102", "D103", "D104", "D105", "D107", "D417", "E203", "E501"]
ignore = [
"B026", # B026: Star-arg unpacking after a keyword argument is strongly discouraged
"D100", # D100: Missing docstring in public module
"D101", # D101: Missing docstring in public class
"D102", # D102: Missing docstring in public method
"D103", # D103: Missing docstring in public function
"D104", # D104: Missing docstring in public package
"D105", # D105: Missing docstring in magic method
"D107", # D107: Missing docstring in __init__
"D417", # D417: Missing argument descriptions in Docstrings
"E203", # E203: Whitespace before ':'
"E501", # E501: Line too long ({width} > {limit})
]

# Allow fix for all enabled rules (when `--fix`) is provided.
fixable = ["ALL"]
unfixable = []

# Allow unused variables when underscore-prefixed.
# Allow unused variables when underscore-prefixed.
dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"

[tool.ruff.per-file-ignores]
"test/*" = ["F401"] # unused-import
"test/*" = ["F401"] # unused-import

[tool.ruff.lint.pydocstyle]
convention = "google"
Expand Down
Loading

0 comments on commit e4c5d8f

Please sign in to comment.