Skip to content

Commit 7afa620

Browse files
author
Muhammad Labeeb
committed
feat: migrate from pylint/black to ruff
1 parent c6a0d16 commit 7afa620

File tree

6 files changed

+26
-11
lines changed

6 files changed

+26
-11
lines changed

.hatch_build.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,5 @@ def load_about() -> dict[str, str]:
1818
with open(
1919
os.path.join(HERE, "tutordiscovery", "__about__.py"), "rt", encoding="utf-8"
2020
) as f:
21-
exec(f.read(), about) # pylint: disable=exec-used
21+
exec(f.read(), about)
2222
return about

Makefile

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
.DEFAULT_GOAL := help
22
.PHONY: docs
33
SRC_DIRS = ./tutordiscovery ./tests
4-
BLACK_OPTS = --exclude templates ${SRC_DIRS}
54

65
# Warning: These checks are run on every PR.
76
test: test-lint test-types test-format test-unit # Run some static checks.
87

98
test-format: ## Run code formatting tests.
10-
black --check --diff $(BLACK_OPTS)
9+
ruff format --check --diff ${SRC_DIRS}
1110

1211
test-lint: ## Run code linting tests
13-
pylint --errors-only --enable=unused-import,unused-argument --ignore=templates --ignore=docs/_ext ${SRC_DIRS}
12+
ruff check ${SRC_DIRS}
1413

1514
test-types: ## Run type checks.
1615
mypy --exclude=templates --ignore-missing-imports --implicit-reexport --strict ${SRC_DIRS}
@@ -19,10 +18,10 @@ test-unit: ## Run unit tests
1918
python -m unittest discover tests
2019

2120
format: ## Format code automatically.
22-
black $(BLACK_OPTS)
21+
ruff format ${SRC_DIRS}
2322

24-
isort: ## Sort imports. This target is not mandatory because the output may be incompatible with black formatting. Provided for convenience purposes.
25-
isort --skip=templates ${SRC_DIRS}
23+
fix-lint: ## Fix lint errors automatically
24+
ruff check --fix ${SRC_DIRS}
2625

2726
changelog-entry: ## Create a new changelog entry.
2827
scriv create
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
- [Improvement] Migrate from pylint and black to ruff. (by @mlabeeb03)

pyproject.toml

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,7 @@ dynamic = ["version"]
3535
[project.optional-dependencies]
3636
dev = [
3737
"tutor[dev]>=20.0.0,<21.0.0",
38-
"pylint",
39-
"black"
38+
"ruff",
4039
]
4140

4241
# https://packaging.python.org/en/latest/specifications/well-known-project-urls/#well-known-labels
@@ -65,5 +64,21 @@ exclude = ["tests*"]
6564
[tool.hatch.build.targets.wheel]
6665
packages = ["tutordiscovery"]
6766

67+
[tool.ruff]
68+
exclude = ["templates", "docs/_ext"]
69+
70+
[tool.ruff.lint]
71+
# E: pycodestyle errors
72+
# I: isort
73+
# N: pep8-naming
74+
select = ["E", "I", "N"]
75+
76+
# F401: unused-import
77+
# F841: unused-variable
78+
# W292: missing-newline-at-end-of-file
79+
extend-select = ["F401", "F841", "W292"]
80+
81+
[tool.ruff.format]
82+
6883
[project.entry-points."tutor.plugin.v1"]
6984
discovery = "tutordiscovery.plugin"

tests/test_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def test_is_docker_rootless(self, mock_run: MagicMock) -> None:
2020

2121
@patch("subprocess.run")
2222
def test_is_docker_rootless_podman(self, mock_run: MagicMock) -> None:
23-
"""Test the `is_docker_rootless` when podman is used or any other error with `docker info`"""
23+
"""Test the `is_docker_rootless` when podman is used or any other error with `docker info`""" # noqa: E501
2424
utils.is_docker_rootless.cache_clear()
2525
mock_run.side_effect = subprocess.CalledProcessError(1, "docker info")
2626
self.assertFalse(utils.is_docker_rootless())

tutordiscovery/plugin.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
config: t.Dict[str, t.Dict[str, t.Any]] = {
2323
"defaults": {
2424
"VERSION": __version__,
25-
"DOCKER_IMAGE": "{{ DOCKER_REGISTRY}}overhangio/openedx-discovery:{{ DISCOVERY_VERSION }}",
25+
"DOCKER_IMAGE": "{{ DOCKER_REGISTRY}}overhangio/openedx-discovery:{{ DISCOVERY_VERSION }}", # noqa: E501
2626
"HOST": "discovery.{{ LMS_HOST }}",
2727
"INDEX_OVERRIDES": {},
2828
"MYSQL_DATABASE": "discovery",

0 commit comments

Comments
 (0)