Skip to content

Commit

Permalink
chore: add reserved keywords linter (#144)
Browse files Browse the repository at this point in the history
  • Loading branch information
arbabkhalil authored Jan 12, 2024
1 parent 814159d commit dd0ca64
Show file tree
Hide file tree
Showing 9 changed files with 45 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
matrix:
os: [ubuntu-20.04]
python-version: ['3.8']
toxenv: [quality, django32, django42]
toxenv: [quality, django32, django42, check_keywords]
steps:
- uses: actions/checkout@v4
- name: setup pythons
Expand Down
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.PHONY: clean compile_translations coverage diff_cover docs dummy_translations \
extract_translations fake_translations help pii_check pull_translations push_translations \
quality requirements selfcheck test test-all upgrade validate
quality requirements selfcheck test test-all upgrade validate check_keywords

.DEFAULT_GOAL := help

Expand Down Expand Up @@ -123,3 +123,6 @@ dummy_translations: ## generate dummy translation (.po) files
build_dummy_translations: extract_translations dummy_translations compile_translations ## generate and compile dummy translation files

validate_translations: build_dummy_translations detect_changed_source_translations ## validate translations

check_keywords: ## Scan the Django models in all installed apps in this project for restricted field names
python manage.py check_reserved_keywords --override_file db_keyword_overrides.yml
10 changes: 10 additions & 0 deletions db_keyword_overrides.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# This file is used by the 'check_reserved_keywords' management command to allow specific field names to be overridden
# when checking for conflicts with lists of restricted keywords used in various database/data warehouse tools.
# For more information, see: https://github.com/edx/edx-django-release-util/release_util/management/commands/check_reserved_keywords.py
#
# overrides should be added in the following format:
# - ModelName.field_name
---
MYSQL:
SNOWFLAKE:
STITCH:
8 changes: 7 additions & 1 deletion requirements/doc.txt
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ django==3.2.23
# django-waffle
# djangorestframework
# drf-jwt
# edx-django-release-util
# edx-django-utils
# edx-drf-extensions
django-crum==0.7.9
Expand Down Expand Up @@ -89,6 +90,8 @@ drf-jwt==1.19.2
# via
# -r requirements/test.txt
# edx-drf-extensions
edx-django-release-util==1.3.0
# via -r requirements/test.txt
edx-django-utils==5.9.0
# via
# -r requirements/test.txt
Expand Down Expand Up @@ -198,6 +201,7 @@ pyyaml==6.0.1
# via
# -r requirements/test.txt
# code-annotations
# edx-django-release-util
readme-renderer==42.0
# via -r requirements/doc.in
requests==2.31.0
Expand All @@ -212,7 +216,9 @@ semantic-version==2.10.0
# -r requirements/test.txt
# edx-drf-extensions
six==1.16.0
# via -r requirements/test.txt
# via
# -r requirements/test.txt
# edx-django-release-util
snowballstemmer==2.2.0
# via sphinx
soupsieve==2.5
Expand Down
5 changes: 5 additions & 0 deletions requirements/quality.txt
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ django==3.2.23
# django-waffle
# djangorestframework
# drf-jwt
# edx-django-release-util
# edx-django-utils
# edx-drf-extensions
django-crum==0.7.9
Expand All @@ -82,6 +83,8 @@ drf-jwt==1.19.2
# via
# -r requirements/test.txt
# edx-drf-extensions
edx-django-release-util==1.3.0
# via -r requirements/test.txt
edx-django-utils==5.9.0
# via
# -r requirements/test.txt
Expand Down Expand Up @@ -202,6 +205,7 @@ pyyaml==6.0.1
# via
# -r requirements/test.txt
# code-annotations
# edx-django-release-util
requests==2.31.0
# via
# -r requirements/test.txt
Expand All @@ -213,6 +217,7 @@ semantic-version==2.10.0
six==1.16.0
# via
# -r requirements/test.txt
# edx-django-release-util
# edx-lint
snowballstemmer==2.2.0
# via pydocstyle
Expand Down
1 change: 1 addition & 0 deletions requirements/test.in
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ pytest-cov # pytest extension for code coverage statistics
pytest-django # pytest extension for better Django support
code-annotations # provides commands used by the pii_check make target.
ddt
edx-django-release-util # Contains the reserved keyword check
11 changes: 9 additions & 2 deletions requirements/test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ ddt==1.7.0
# django-waffle
# djangorestframework
# drf-jwt
# edx-django-release-util
# edx-django-utils
# edx-drf-extensions
django-crum==0.7.9
Expand All @@ -68,6 +69,8 @@ drf-jwt==1.19.2
# via
# -r requirements/base.txt
# edx-drf-extensions
edx-django-release-util==1.3.0
# via -r requirements/test.in
edx-django-utils==5.9.0
# via
# -r requirements/base.txt
Expand Down Expand Up @@ -140,7 +143,9 @@ pytz==2023.3.post1
# django
# djangorestframework
pyyaml==6.0.1
# via code-annotations
# via
# code-annotations
# edx-django-release-util
requests==2.31.0
# via
# -r requirements/base.txt
Expand All @@ -150,7 +155,9 @@ semantic-version==2.10.0
# -r requirements/base.txt
# edx-drf-extensions
six==1.16.0
# via -r requirements/base.txt
# via
# -r requirements/base.txt
# edx-django-release-util
sqlparse==0.4.4
# via
# -r requirements/base.txt
Expand Down
1 change: 1 addition & 0 deletions test_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ def root(*args):
'django.contrib.contenttypes',
'edx_rbac',
'tests',
'release_util',
)

LOCALE_PATHS = [
Expand Down
7 changes: 7 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,10 @@ deps =
commands =
code_annotations django_find_annotations --config_file .pii_annotations.yml --lint --report --coverage

[testenv:check_keywords]
allowlist_externals =
make
deps =
-r{toxinidir}/requirements/test.txt
commands =
make check_keywords

0 comments on commit dd0ca64

Please sign in to comment.