Compare commits

...

2 Commits

Author SHA1 Message Date
Florian du Garage Num
61c9b3e23c remove hard-coded uid 1000
Some checks failed
Run tests / tests (3.12) (push) Has been cancelled
Run tests / tests (3.9) (push) Has been cancelled
Sync with private repo / sync (push) Has been cancelled
2025-09-30 21:48:26 +02:00
Abdul Rehman
13da199f04
feat: migrate from pylint/black to ruff (#42) 2025-09-03 21:53:45 +05:00
7 changed files with 40 additions and 15 deletions

View File

@ -17,5 +17,5 @@ class MetaDataHook(MetadataHookInterface):
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

View File

@ -1,25 +1,30 @@
.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}
format: ## Format code automatically
black $(BLACK_OPTS)
build-pythonpackage: ## Build the "tutor-xqueue" python package for upload to pypi
python -m build --sdist
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}
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
ruff format ${SRC_DIRS}
fix-lint: ## Fix lint errors automatically
ruff check --fix ${SRC_DIRS}
changelog-entry: ## Create a new changelog entry.
scriv create
@ -27,6 +32,9 @@ changelog-entry: ## Create a new changelog entry.
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 \

View File

@ -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)

View File

@ -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
@ -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]

View File

@ -1 +1 @@
setowner 1000 /mounts/xqueue
setowner {{ APP_USER_ID }} /mounts/xqueue

View File

@ -23,7 +23,7 @@ config: dict[str, dict[str, Any]] = {
"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",
@ -200,7 +200,7 @@ class Client:
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]:

View File

@ -21,7 +21,7 @@ RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
RUN ln -s /usr/bin/python3 /usr/bin/python
###### Git-clone xqueue repo ######
ARG APP_USER_ID=1000
ARG APP_USER_ID={{ HOST_USER_ID }}
RUN useradd --home-dir /openedx --create-home --shell /bin/bash --uid ${APP_USER_ID} app
USER ${APP_USER_ID}