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

project: Add ruff check to tox #762

Merged
merged 2 commits into from
Nov 4, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
16 changes: 8 additions & 8 deletions src/west/manifest.py
Original file line number Diff line number Diff line change
Expand Up @@ -2147,7 +2147,7 @@ def _import_from_self(self, imp: Any) -> None:
# system) with a fallback on self._ctx.project_importer.

imptype = type(imp)
if imptype == bool:
if imptype is bool:
self._malformed(f'got "self: import: {imp}" of boolean')
elif self._ctx.import_flags & ImportFlag.IGNORE:
# If we're ignoring imports altogether, this is fine.
Expand All @@ -2171,12 +2171,12 @@ def _import_from_self(self, imp: Any) -> None:
self._assert_imports_ok()
self.has_imports = True

if imptype == str:
if imptype is str:
self._import_path_from_self(imp)
elif imptype == list:
elif imptype is list:
for subimp in imp:
self._import_from_self(subimp)
elif imptype == dict:
elif imptype is dict:
self._import_map_from_self(imp)
else:
self._malformed(
Expand Down Expand Up @@ -2505,16 +2505,16 @@ def _import_from_project(self, project: Project, imp: Any):
self.has_imports = True

imptype = type(imp)
if imptype == bool:
if imptype is bool:
# We should not have been called unless the import was truthy.
assert imp
self._import_path_from_project(project, _WEST_YML)
elif imptype == str:
elif imptype is str:
self._import_path_from_project(project, imp)
elif imptype == list:
elif imptype is list:
for subimp in imp:
self._import_from_project(project, subimp)
elif imptype == dict:
elif imptype is dict:
self._import_map_from_project(project, imp)
else:
self._malformed(f'{project.name_and_path}: invalid import {imp} '
Expand Down
2 changes: 2 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,12 @@ deps =
types-PyYAML
flake8
mypy
ruff
setenv =
# For instance: ./.tox/py3/tmp/
TOXTEMPDIR={envtmpdir}
commands =
python -m pytest --cov-report=html --cov=west {posargs:tests} --basetemp='{envtmpdir}/pytest with space/'
python -m flake8 --config='{toxinidir}'/tox.ini '{toxinidir}'
python -m ruff check '{toxinidir}'
python -m mypy --config-file='{toxinidir}'/tox.ini --package=west