Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add reserved keywords linter #166

Merged
merged 7 commits into from
Jan 12, 2024
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/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@v3
Expand Down
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.PHONY: clean quality requirements test upgrade
.PHONY: clean quality requirements test upgrade check_keywords

clean:
coverage erase
Expand Down Expand Up @@ -45,3 +45,6 @@ upgrade: $(COMMON_CONSTRAINTS_TXT) ## update the requirements/*.txt files with
# Let tox control the Django version for tests
sed '/^[dD]jango==/d' requirements/test.txt > requirements/test.tmp
mv requirements/test.tmp requirements/test.txt

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:
5 changes: 5 additions & 0 deletions requirements/dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,10 @@ django==3.2.23
# via
# -c requirements/common_constraints.txt
# -r requirements/test.txt
# edx-django-release-util
# social-auth-app-django
edx-django-release-util==1.3.0
# via -r requirements/test.txt
edx-lint==5.3.6
# via -r requirements/test.txt
exceptiongroup==1.2.0
Expand Down Expand Up @@ -222,6 +225,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 @@ -235,6 +239,7 @@ six==1.16.0
# via
# -r requirements/ci.txt
# -r requirements/test.txt
# edx-django-release-util
# edx-lint
# tox
# unittest2
Expand Down
1 change: 1 addition & 0 deletions requirements/test.in
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ pytest-cov
pytest-django
tox
unittest2
edx-django-release-util # Contains the reserved keyword check
8 changes: 7 additions & 1 deletion requirements/test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,10 @@ distlib==0.3.8
# via
# -c requirements/common_constraints.txt
# -r requirements/base.txt
# edx-django-release-util
# social-auth-app-django
edx-django-release-util==1.3.0
# via -r requirements/test.in
edx-lint==5.3.6
# via -r requirements/test.in
exceptiongroup==1.2.0
Expand Down Expand Up @@ -150,7 +153,9 @@ pytz==2023.3.post1
# -r requirements/base.txt
# django
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 @@ -163,6 +168,7 @@ requests-oauthlib==1.3.1
six==1.16.0
# via
# -r requirements/base.txt
# edx-django-release-util
# edx-lint
# tox
# unittest2
Expand Down
1 change: 1 addition & 0 deletions test_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
'django.contrib.sessions',
'social_django',
'auth_backends',
'release_util',
)

DATABASES = {
Expand Down
7 changes: 7 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,10 @@ commands =
pycodestyle --config=.pep8 auth_backends
pylint --rcfile=pylintrc auth_backends

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