updated package setup (#485)

* updated package setup

* updated to use python 3.9

* fixed test runner

* fixed typecheck tests

* fixed discrepencies

* added override to runner

* updated travis

* updated pre-commit hooks

* updated dep
This commit is contained in:
Na'aman Hirschfeld
2020-10-29 09:59:48 +01:00
committed by GitHub
parent a3624dec36
commit 44151c485d
74 changed files with 1141 additions and 1446 deletions

View File

@@ -3,28 +3,27 @@ from pytest_mypy_plugins.item import YamlTestItem
def django_plugin_hook(test_item: YamlTestItem) -> None:
custom_settings = test_item.parsed_test_data.get('custom_settings', '')
installed_apps = test_item.parsed_test_data.get('installed_apps', None)
custom_settings = test_item.parsed_test_data.get("custom_settings", "")
installed_apps = test_item.parsed_test_data.get("installed_apps", None)
if installed_apps and custom_settings:
raise ValueError('"installed_apps" and "custom_settings" are not compatible, please use one or the other')
if installed_apps is not None:
# custom_settings is empty, add INSTALLED_APPS
installed_apps += ['django.contrib.contenttypes']
installed_apps_as_str = '(' + ','.join([repr(app) for app in installed_apps]) + ',)'
custom_settings += 'INSTALLED_APPS = ' + installed_apps_as_str
installed_apps += ["django.contrib.contenttypes"]
installed_apps_as_str = "(" + ",".join([repr(app) for app in installed_apps]) + ",)"
custom_settings += "INSTALLED_APPS = " + installed_apps_as_str
if 'SECRET_KEY' not in custom_settings:
if "SECRET_KEY" not in custom_settings:
custom_settings = 'SECRET_KEY = "1"\n' + custom_settings
django_settings_section = "\n[mypy.plugins.django-stubs]\n" \
"django_settings_module = mysettings"
django_settings_section = "\n[mypy.plugins.django-stubs]\n" "django_settings_module = mysettings"
if not test_item.additional_mypy_config:
test_item.additional_mypy_config = django_settings_section
else:
if '[mypy.plugins.django-stubs]' not in test_item.additional_mypy_config:
if "[mypy.plugins.django-stubs]" not in test_item.additional_mypy_config:
test_item.additional_mypy_config += django_settings_section
mysettings_file = File(path='mysettings.py', content=custom_settings)
mysettings_file = File(path="mysettings.py", content=custom_settings)
test_item.files.append(mysettings_file)