From afe557f40c7f1e4beb87d3d8763e18be869c9c8c Mon Sep 17 00:00:00 2001 From: Arbab Khalil Date: Tue, 25 Jan 2022 18:43:28 +0500 Subject: [PATCH 1/3] chore: add reserved keywords linter --- .github/workflows/ci.yml | 2 +- Makefile | 5 ++++- db_keyword_overrides.yml | 10 ++++++++++ tox.ini | 7 +++++++ 4 files changed, 22 insertions(+), 2 deletions(-) create mode 100644 db_keyword_overrides.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d3fdad1..8623838 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,7 +14,7 @@ jobs: matrix: os: [ubuntu-20.04] python-version: ['3.8'] - toxenv: [django30, django31, django32, docs, quality] + toxenv: [django30, django31, django32, docs, quality, check_keywords] steps: - uses: actions/checkout@v2 diff --git a/Makefile b/Makefile index 35824a1..888c8a8 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -.PHONY: clean coverage docs help quality requirements test test-all upgrade +.PHONY: clean coverage docs help quality requirements test test-all upgrade check_keywords .DEFAULT_GOAL := help @@ -65,3 +65,6 @@ diff_cover: test test-all: ## run tests on every supported Python/Django combination tox -e quality tox + +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 diff --git a/db_keyword_overrides.yml b/db_keyword_overrides.yml new file mode 100644 index 0000000..dcc39cd --- /dev/null +++ b/db_keyword_overrides.yml @@ -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: diff --git a/tox.ini b/tox.ini index f6ba494..c9e9d2f 100644 --- a/tox.ini +++ b/tox.ini @@ -46,3 +46,10 @@ commands = isort --check-only web_fragments manage.py setup.py test_settings.py make help +[testenv:check_keywords] +whitelist_externals = + make +deps = + -r{toxinidir}/requirements/test.txt +commands = + make check_keywords From c021f82ac4b452d427aca2a6cc7c62ff8c5dd830 Mon Sep 17 00:00:00 2001 From: Arbab Khalil Date: Tue, 25 Jan 2022 18:52:36 +0500 Subject: [PATCH 2/3] chore: add reserved keywords linter --- tox.ini | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tox.ini b/tox.ini index c9e9d2f..478e05c 100644 --- a/tox.ini +++ b/tox.ini @@ -47,6 +47,9 @@ commands = make help [testenv:check_keywords] +setenv = + DJANGO_SETTINGS_MODULE = test_settings + PYTHONPATH = {toxinidir} whitelist_externals = make deps = From 4acd71e58684173c235b15d51f99656de8c5f298 Mon Sep 17 00:00:00 2001 From: Rebecca Graber Date: Fri, 12 Jan 2024 13:36:54 -0500 Subject: [PATCH 3/3] fixup!: s/white/allow/ --- tox.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tox.ini b/tox.ini index 7ef9e9a..47c34d9 100644 --- a/tox.ini +++ b/tox.ini @@ -55,7 +55,7 @@ commands = setenv = DJANGO_SETTINGS_MODULE = test_settings PYTHONPATH = {toxinidir} -whitelist_externals = +allowlist_externals = make deps = -r{toxinidir}/requirements/test.txt