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 .github/workflows/quality-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ jobs:
PIP_SRC: ${{ runner.temp }}
TARGET_BRANCH: ${{ github.base_ref }}
run: |
make pycodestyle
ruff check --output-format=github .
make xsslint
make pii_check
make check_keywords
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,8 @@ xsslint: ## check xss for quality issuest
--config=scripts.xsslint_config \
--thresholds=scripts/xsslint_thresholds.json

pycodestyle: ## check python files for quality issues
pycodestyle .
ruff: ## check python files with ruff
ruff check .

## Re-enable --lint flag when this issue https://github.com/openedx/edx-platform/issues/35775 is resolved
pii_check: ## check django models for pii annotations
Expand Down
2 changes: 1 addition & 1 deletion cms/djangoapps/contentstore/views/tests/test_block.py
Original file line number Diff line number Diff line change
Expand Up @@ -3506,7 +3506,7 @@ def validate_xblock_info_consistency(
self.validate_xblock_info_consistency(
child_response,
has_child_info=(
not child_response.get("child_info", None) is None
child_response.get("child_info", None) is not None
),
course_outline=course_outline,
)
Expand Down
21 changes: 21 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,27 @@ norecursedirs = ". .* *.egg build conf dist node_modules test_root cms/envs lms/
python_classes = []
python_files = ["tests.py", "test_*.py", "tests_*.py", "*_tests.py", "__init__.py"]

[tool.ruff]
line-length = 120
exclude = [
"migrations",
"test_root/staticfiles",
]

[tool.ruff.lint]
select = ["E", "W"]
ignore = [
"E402", # module level import not at top of file
"E501", # line too long (pylint enforces this at 120 chars while ignoring trailing comments)
"E722", # do not use bare 'except'
"E731", # do not assign a lambda expression
"E741", # ambiguous variable name. TODO: fix the ~9 issues and re-enable this.
# The rules below were added in pycodestyle 2.9.x but we were pinned to 2.8.x,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

W503 and W504 (line break before/after binary operator) were both ignored in the old setup.cfg pycodestyle config but are absent here. That is intentional: ruff does not implement either rule.

These two rules are mutually contradictory — one requires breaking before the operator, the other after — so PEP 8 guidance on this has gone back and forth over the years. Ruff took the pragmatic approach of not enforcing either one, meaning whatever line-break style the codebase already uses will be accepted as-is.

# so they represent new findings. Keeping them ignored here to make this an
# equivalent swap; they can be cleaned up in a follow-up.
"E721", # use `isinstance()` for type comparisons
]

[tool.isort]
indent = " "
line_length = 120
Expand Down
5 changes: 0 additions & 5 deletions requirements/constraints.txt
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,6 @@ openai<=0.28.1
# Issue for unpinning: https://github.com/openedx/edx-platform/issues/35267
path<16.12.0

# Date: 2022-08-03
# pycodestyle==2.9.0 generates false positive error E275.
# Constraint can be removed once the issue https://github.com/PyCQA/pycodestyle/issues/1090 is fixed.
pycodestyle<2.9.0

# Date: 2021-08-25
# At the time of writing this comment, we do not know whether py2neo>=2022
# will support our currently-deployed Neo4j version (3.5).
Expand Down
6 changes: 2 additions & 4 deletions requirements/edx/development.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1570,10 +1570,6 @@ pycasbin==2.8.0
# -r requirements/edx/testing.txt
# casbin-django-orm-adapter
# openedx-authz
pycodestyle==2.8.0
# via
# -c requirements/constraints.txt
# -r requirements/edx/testing.txt
pycountry==26.2.16
# via
# -r requirements/edx/doc.txt
Expand Down Expand Up @@ -1899,6 +1895,8 @@ rsa==4.9.1
# -r requirements/edx/doc.txt
# -r requirements/edx/testing.txt
# google-auth
ruff==0.15.4
# via -r requirements/edx/testing.txt
rules==3.5
# via
# -r requirements/edx/doc.txt
Expand Down
2 changes: 1 addition & 1 deletion requirements/edx/testing.in
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ httpretty # Library for mocking HTTP requests, used in many test
import-linter # Tool for making assertions about which modules can import which others
isort # For checking and fixing the order of imports
mock # Deprecated alias to standard library `unittest.mock`
pycodestyle # Checker for compliance with the Python style guide (PEP 8)
ruff # Fast Python linter and formatter
polib # Library for manipulating gettext translation files, used to test paver i18n commands
pyquery # jQuery-like API for retrieving fragments of HTML and XML files in tests
pytest # Testing framework
Expand Down
6 changes: 2 additions & 4 deletions requirements/edx/testing.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1199,10 +1199,6 @@ pycasbin==2.8.0
# -r requirements/edx/base.txt
# casbin-django-orm-adapter
# openedx-authz
pycodestyle==2.8.0
# via
# -c requirements/constraints.txt
# -r requirements/edx/testing.in
pycountry==26.2.16
# via -r requirements/edx/base.txt
pycparser==3.0
Expand Down Expand Up @@ -1452,6 +1448,8 @@ rsa==4.9.1
# via
# -r requirements/edx/base.txt
# google-auth
ruff==0.15.4
# via -r requirements/edx/testing.in
rules==3.5
# via
# -r requirements/edx/base.txt
Expand Down
22 changes: 0 additions & 22 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,22 +0,0 @@
[pycodestyle]
# error codes: https://pycodestyle.readthedocs.io/en/latest/intro.html#error-codes
# E501: line too long
# E265: block comment should start with '# '
# We ignore this because pep8 used to erroneously lump E266 into it also.
# We should probably fix these now.
# E266: too many leading '#' for block comment
# We have lots of comments that look like "##### HEADING #####" which violate
# this rule, because they don't have a space after the first #. However,
# they're still perfectly reasonable comments, so we disable this rule.
# W602: deprecated form of raising exception
# We do this in a few places to modify the exception message while preserving
# the traceback. See this blog post for more info:
# http://nedbatchelder.com/blog/200711/rethrowing_exceptions_in_python.html
# It's a little unusual, but we have good reasons for doing so, so we disable
# this rule.
# E203: whitespace before ':'
# We ignore this because of black formatter defaults
# E305,E402,E722,E731,E741,E743,W503,W504: errors and warnings added since pep8/pycodestyle
# 1.5.7 that we haven't cleaned up yet
ignore=E203,E265,E266,E305,E402,E501,E722,E731,E741,E743,W503,W504,W602
exclude=migrations,.git,.pycharm_helpers,.tox,test_root/staticfiles,node_modules
Loading