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

Use ruff to lint/format/isort #476

Open
wants to merge 21 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 14 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions .flake8

This file was deleted.

6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ clean:
find . -type d -name '__pycache__' | xargs rm -rf

_lint:
flake8 --exclude=**/gen/**,*_grpc.py,*_pb2.py,*_pb2.pyi,.tox
ruff --exclude=*_grpc.py,*_pb2.py,*_pb2.pyi,.tox .

lint:
poetry run $(MAKE) _lint

_format:
black --exclude ".*/gen/.*" ./src
isort ./src
ruff format ./src
ruff --select I001 --fix ./src

format:
poetry run $(MAKE) _format
Expand Down
48 changes: 27 additions & 21 deletions poetry.lock

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

17 changes: 9 additions & 8 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ include = ["LICENSE", "src/viam/rpc/libviam_rust_utils.*"]
pytest-watcher = "^0.3.4"
# TODO(RSDK-5450) - Update myst-nb so this can be unpinned.
astroid = "<=2.15.6"
ruff = "^0.1.3"

[tool.pytest.ini_options]
addopts = "-ra"
Expand All @@ -51,17 +52,17 @@ omit = [ "*/gen/*" ]
[tool.coverage.report]
exclude_lines = [ "pragma: no\\s*cover", "\\.\\.\\." ]

[tool.black]
line-length = 140

[tool.isort]
profile = "black"
skip_glob = ["**/gen/**"]
line_length = 140

[build-system]
requires = [ "poetry-core>=1.0.0" ]
build-backend = "poetry.core.masonry.api"

[tool.poetry.extras]
mlmodel = ["numpy"]

[tool.ruff]
line-length = 140
ignore = ["E203"]
extend-exclude = ["**/gen/**"]

[tool.ruff.extend-per-file-ignores]
"__init__.py" = ["F401"]
14 changes: 4 additions & 10 deletions src/viam/app/app_client.py
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I couldn't get this one in parity, but might be fine?

Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,6 @@
DeleteRobotPartRequest,
DeleteRobotPartSecretRequest,
DeleteRobotRequest,
)
from viam.proto.app import Fragment as FragmentPB
from viam.proto.app import (
GetFragmentRequest,
GetFragmentResponse,
GetLocationRequest,
Expand Down Expand Up @@ -67,9 +64,6 @@
LocationAuth,
LocationAuthRequest,
LocationAuthResponse,
)
from viam.proto.app import LogEntry as LogEntryPB
from viam.proto.app import (
MarkPartAsMainRequest,
MarkPartForRestartRequest,
Model,
Expand All @@ -85,10 +79,6 @@
OrgDetails,
RemoveRoleRequest,
Robot,
)
from viam.proto.app import RobotPart as RobotPartPB
from viam.proto.app import RobotPartHistoryEntry as RobotPartHistoryEntryPB
from viam.proto.app import (
SharedSecret,
TailRobotPartLogsRequest,
TailRobotPartLogsResponse,
Expand All @@ -107,6 +97,10 @@
UploadModuleFileRequest,
Visibility,
)
from viam.proto.app import Fragment as FragmentPB
from viam.proto.app import LogEntry as LogEntryPB
from viam.proto.app import RobotPart as RobotPartPB
from viam.proto.app import RobotPartHistoryEntry as RobotPartHistoryEntryPB
from viam.utils import datetime_to_timestamp, dict_to_struct, struct_to_dict

LOGGER = logging.getLogger(__name__)
Expand Down
2 changes: 1 addition & 1 deletion src/viam/resource/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class ResourceCreatorRegistration:
"""A function that can create a resource given a mapping of dependencies (``ResourceName`` to ``ResourceBase``
"""

validator: "Validator" = lambda x: []
validator: "Validator" = lambda x: [] # noqa: E731
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also wasn't able to figure this one out

"""A function that can validate a resource and return implicit dependencies.

If called without a validator function, default to a function returning an empty Sequence
Expand Down
Loading