Skip to content
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
2 changes: 1 addition & 1 deletion .hatch_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ def update(self, metadata: dict[str, t.Any]) -> None:
def load_about() -> dict[str, str]:
about: dict[str, str] = {}
with open(os.path.join(HERE, "tutorxqueue", "__about__.py"), "rt", encoding="utf-8") as f:
exec(f.read(), about) # pylint: disable=exec-used
exec(f.read(), about)
return about
22 changes: 15 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,32 +1,40 @@
.DEFAULT_GOAL := help
.PHONY: docs
SRC_DIRS = ./tutorxqueue
BLACK_OPTS = --exclude templates ${SRC_DIRS}

# Warning: These checks are not necessarily run on every PR.
test: test-lint test-types test-format # Run some static checks.
test: test-lint test-format test-types test-pythonpackage # Run some static checks.

test-format: ## Run code formatting tests
black --check --diff $(BLACK_OPTS)
ruff format --check --diff $(SRC_DIRS)

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

test-types: ## Run type checks.
mypy --exclude=templates --ignore-missing-imports --implicit-reexport --strict ${SRC_DIRS}

build-pythonpackage: ## Build the "tutor-xqueue" python package for upload to pypi
python -m build --sdist

test-pythonpackage: build-pythonpackage ## Test that package can be uploaded to pypi
twine check dist/tutor_xqueue-$(shell make version).tar.gz

format: ## Format code automatically
black $(BLACK_OPTS)
ruff format ${SRC_DIRS}

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

changelog-entry: ## Create a new changelog entry.
scriv create

changelog: ## Collect changelog entries in the CHANGELOG.md file.
scriv collect

version: ## Print the current tutor-xqueue version
@python -c 'import io, os; about = {}; exec(io.open(os.path.join("tutorxqueue", "__about__.py"), "rt", encoding="utf-8").read(), about); print(about["__version__"])'

ESCAPE = 
help: ## Print this help
@grep -E '^([a-zA-Z_-]+:.*?## .*|######* .+)$$' Makefile \
Expand Down
2 changes: 2 additions & 0 deletions changelog.d/20250806_163740_abdul.rehman02_migrate_ruff.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- [Improvement] Migrate from pylint and black to ruff. (by @rehmansheikh222)
- [Improvement] Test python package distribution build when running make test. (by @rehmansheikh222)
19 changes: 17 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ dynamic = ["version"]
[project.optional-dependencies]
dev = [
"tutor[dev]>=20.0.0,<21.0.0",
"black",
"pylint"
"ruff"
]

# https://packaging.python.org/en/latest/specifications/well-known-project-urls/#well-known-labels
Expand Down Expand Up @@ -68,3 +67,19 @@ exclude = ["tests*"]

[project.entry-points."tutor.plugin.v1"]
xqueue = "tutorxqueue.plugin"

[tool.ruff]
exclude = ["templates", "docs/_ext"]

[tool.ruff.lint]
# E: pycodestyle errors
# I: isort
# N: pep8-naming
select = ["E", "I", "N"]

# F401: unused-import
# F841: unused-variable
# W292: missing-newline-at-end-of-file
extend-select = ["F401", "F841", "W292"]

[tool.ruff.format]
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this needed at the end?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Currently, we’re not using any custom ruff format options, so this section is not required. I left it in place to make it easier to add formatting rules in the future without restructuring the config, but I’m fine with removing it if we prefer to keep only actively used sections.

4 changes: 2 additions & 2 deletions tutorxqueue/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"defaults": {
"VERSION": __version__,
"AUTH_USERNAME": "lms",
"DOCKER_IMAGE": "{{ DOCKER_REGISTRY }}overhangio/openedx-xqueue:{{ XQUEUE_VERSION }}",
"DOCKER_IMAGE": "{{ DOCKER_REGISTRY }}overhangio/openedx-xqueue:{{ XQUEUE_VERSION }}", # noqa: E501
"HOST": "xqueue.{{ LMS_HOST }}",
"MYSQL_DATABASE": "xqueue",
"MYSQL_USERNAME": "xqueue",
Expand Down Expand Up @@ -200,7 +200,7 @@ def login(self) -> None:
message = response.get("content")
if message != "Logged in":
raise exceptions.TutorError(
f"Could not login to xqueue server at {self.base_url}. Response: '{message}'"
f"Could not login to xqueue server at {self.base_url}. Response: '{message}'" # noqa: E501
)

def show_submission(self, queue: str) -> Union[dict[str, Any], Any]:
Expand Down