diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 4602c6bd..ebf58642 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -33,7 +33,7 @@ repos: - id: pyupgrade args: [--py38-plus] - repo: https://github.com/psf/black-pre-commit-mirror - rev: 23.12.1 + rev: 24.1.1 hooks: - id: black - repo: https://github.com/adamchainz/blacken-docs diff --git a/src/django_upgrade/fixers/admin_allow_tags.py b/src/django_upgrade/fixers/admin_allow_tags.py index bcf478c9..79325590 100644 --- a/src/django_upgrade/fixers/admin_allow_tags.py +++ b/src/django_upgrade/fixers/admin_allow_tags.py @@ -3,6 +3,7 @@ https://docs.djangoproject.com/en/2.0/releases/2.0/#features-removed-in-2-0 """ + from __future__ import annotations import ast diff --git a/src/django_upgrade/fixers/admin_decorators.py b/src/django_upgrade/fixers/admin_decorators.py index cda397f8..c94ca972 100644 --- a/src/django_upgrade/fixers/admin_decorators.py +++ b/src/django_upgrade/fixers/admin_decorators.py @@ -4,6 +4,7 @@ https://docs.djangoproject.com/en/3.2/ref/contrib/admin/actions/#django.contrib.admin.action https://docs.djangoproject.com/en/3.2/ref/contrib/admin/#django.contrib.admin.display """ + from __future__ import annotations import ast diff --git a/src/django_upgrade/fixers/admin_lookup_needs_distinct.py b/src/django_upgrade/fixers/admin_lookup_needs_distinct.py index 4965628d..7e9d2f32 100644 --- a/src/django_upgrade/fixers/admin_lookup_needs_distinct.py +++ b/src/django_upgrade/fixers/admin_lookup_needs_distinct.py @@ -2,6 +2,7 @@ Rename django.contrib.admin.utils.lookup_needs_distinct to lookup_spawns_duplicates: https://docs.djangoproject.com/en/4.0/releases/4.0/#miscellaneous """ + from __future__ import annotations import ast diff --git a/src/django_upgrade/fixers/admin_register.py b/src/django_upgrade/fixers/admin_register.py index 0a6a8627..b60e6b62 100644 --- a/src/django_upgrade/fixers/admin_register.py +++ b/src/django_upgrade/fixers/admin_register.py @@ -2,6 +2,7 @@ Replace `admin.site.register` with the new `@register` decorator syntax: https://docs.djangoproject.com/en/stable/releases/1.7/#minor-features """ + from __future__ import annotations import ast @@ -47,9 +48,9 @@ def __init__(self, parent: ast.AST, lineno: int) -> None: decorable_admins: MutableMapping[State, dict[str, AdminDetails]] = WeakKeyDictionary() # Name of site to set of unregistered model names, or True if potentially all # models have been unregistered -unregistered_site_models: MutableMapping[ - State, dict[str, set[str] | Literal[True]] -] = WeakKeyDictionary() +unregistered_site_models: MutableMapping[State, dict[str, set[str] | Literal[True]]] = ( + WeakKeyDictionary() +) def _is_django_admin_imported(state: State) -> bool: @@ -265,9 +266,9 @@ def visit_Call( existing_names.update(unregistered_names) -site_definitions: MutableMapping[ - ast.Module, dict[str, int | None] -] = WeakKeyDictionary() +site_definitions: MutableMapping[ast.Module, dict[str, int | None]] = ( + WeakKeyDictionary() +) def get_site_defined_line(module: ast.AST, site_name: str) -> int | None: diff --git a/src/django_upgrade/fixers/assert_form_error.py b/src/django_upgrade/fixers/assert_form_error.py index eceb8b82..ce197826 100644 --- a/src/django_upgrade/fixers/assert_form_error.py +++ b/src/django_upgrade/fixers/assert_form_error.py @@ -4,6 +4,7 @@ https://docs.djangoproject.com/en/4.1/releases/4.1/#tests """ + from __future__ import annotations import ast diff --git a/src/django_upgrade/fixers/assert_set_methods.py b/src/django_upgrade/fixers/assert_set_methods.py index 4b5719fe..62e5d0a2 100644 --- a/src/django_upgrade/fixers/assert_set_methods.py +++ b/src/django_upgrade/fixers/assert_set_methods.py @@ -3,6 +3,7 @@ capitalized “Set”: https://docs.djangoproject.com/en/4.2/releases/4.2/#miscellaneous """ + from __future__ import annotations import ast diff --git a/src/django_upgrade/fixers/compatibility_imports.py b/src/django_upgrade/fixers/compatibility_imports.py index bfe6291a..850ce19e 100644 --- a/src/django_upgrade/fixers/compatibility_imports.py +++ b/src/django_upgrade/fixers/compatibility_imports.py @@ -12,6 +12,7 @@ - Replace `django.utils.functional.lru_cache` with `functools.lru_cache` Undocumented change """ + from __future__ import annotations import ast diff --git a/src/django_upgrade/fixers/crypto_get_random_string.py b/src/django_upgrade/fixers/crypto_get_random_string.py index 25c54f5c..217c5e53 100644 --- a/src/django_upgrade/fixers/crypto_get_random_string.py +++ b/src/django_upgrade/fixers/crypto_get_random_string.py @@ -2,6 +2,7 @@ Add the 'length' argument to get_random_string(): https://docs.djangoproject.com/en/3.1/releases/3.1/#features-deprecated-in-3-1 """ + from __future__ import annotations import ast diff --git a/src/django_upgrade/fixers/default_app_config.py b/src/django_upgrade/fixers/default_app_config.py index 01c1edd2..795c3a68 100644 --- a/src/django_upgrade/fixers/default_app_config.py +++ b/src/django_upgrade/fixers/default_app_config.py @@ -2,6 +2,7 @@ Remove default_app_config: https://docs.djangoproject.com/en/stable/releases/3.2/#features-deprecated-in-3-2 """ + from __future__ import annotations import ast diff --git a/src/django_upgrade/fixers/django_urls.py b/src/django_upgrade/fixers/django_urls.py index d0a37ea2..bc58e8ef 100644 --- a/src/django_upgrade/fixers/django_urls.py +++ b/src/django_upgrade/fixers/django_urls.py @@ -2,6 +2,7 @@ Update URL definitions: https://docs.djangoproject.com/en/2.0/releases/2.0/#simplified-url-routing-syntax """ + from __future__ import annotations import ast diff --git a/src/django_upgrade/fixers/email_validator.py b/src/django_upgrade/fixers/email_validator.py index 05f047fd..4da5ba82 100644 --- a/src/django_upgrade/fixers/email_validator.py +++ b/src/django_upgrade/fixers/email_validator.py @@ -2,6 +2,7 @@ Rewrite django.core.validator.EmailValidator arguments: https://docs.djangoproject.com/en/3.2/releases/3.2/#features-deprecated-in-3-2 """ + from __future__ import annotations import ast diff --git a/src/django_upgrade/fixers/forms_model_multiple_choice_field.py b/src/django_upgrade/fixers/forms_model_multiple_choice_field.py index 44d35696..8c247252 100644 --- a/src/django_upgrade/fixers/forms_model_multiple_choice_field.py +++ b/src/django_upgrade/fixers/forms_model_multiple_choice_field.py @@ -2,6 +2,7 @@ Replace `list` error message key with `list_invalid` for ModelMultipleChoiceField. https://docs.djangoproject.com/en/3.1/releases/3.1/#id2 """ + from __future__ import annotations import ast diff --git a/src/django_upgrade/fixers/management_commands.py b/src/django_upgrade/fixers/management_commands.py index 56fa6ac3..3dc643db 100644 --- a/src/django_upgrade/fixers/management_commands.py +++ b/src/django_upgrade/fixers/management_commands.py @@ -2,6 +2,7 @@ Replace BaseCommand.requires_system_checks boolean flag by list of checks: https://docs.djangoproject.com/en/stable/releases/3.2/#deprecated-features-3-2 """ + from __future__ import annotations import ast diff --git a/src/django_upgrade/fixers/model_field_choices.py b/src/django_upgrade/fixers/model_field_choices.py index 49bcdc99..21c2abc9 100644 --- a/src/django_upgrade/fixers/model_field_choices.py +++ b/src/django_upgrade/fixers/model_field_choices.py @@ -2,6 +2,7 @@ Drop `.choices` for model field `choices` parameters: https://docs.djangoproject.com/en/5.0/releases/5.0/#forms """ + from __future__ import annotations import ast diff --git a/src/django_upgrade/fixers/null_boolean_field.py b/src/django_upgrade/fixers/null_boolean_field.py index 59080a72..79cd02c1 100644 --- a/src/django_upgrade/fixers/null_boolean_field.py +++ b/src/django_upgrade/fixers/null_boolean_field.py @@ -2,6 +2,7 @@ Rewrite django.db.models.NullBooleanField to BooleanField: https://docs.djangoproject.com/en/3.1/releases/3.1/#features-deprecated-in-3-1 """ + from __future__ import annotations import ast diff --git a/src/django_upgrade/fixers/on_delete.py b/src/django_upgrade/fixers/on_delete.py index cd5f48ad..182f404c 100644 --- a/src/django_upgrade/fixers/on_delete.py +++ b/src/django_upgrade/fixers/on_delete.py @@ -2,6 +2,7 @@ Add on_delete=models.CASCADE to ForeignKey and OneToOneField: https://docs.djangoproject.com/en/stable/releases/1.9/#features-deprecated-in-1-9 """ + from __future__ import annotations import ast diff --git a/src/django_upgrade/fixers/password_reset_timeout_days.py b/src/django_upgrade/fixers/password_reset_timeout_days.py index d24e9109..10c744de 100644 --- a/src/django_upgrade/fixers/password_reset_timeout_days.py +++ b/src/django_upgrade/fixers/password_reset_timeout_days.py @@ -2,6 +2,7 @@ PASSWORD_RESET_TIMEOUT_DAYS setting replaced with PASSWORD_RESET_TIMEOUT: https://docs.djangoproject.com/en/3.1/releases/3.1/#django-contrib-auth """ + from __future__ import annotations import ast diff --git a/src/django_upgrade/fixers/postgres_float_range_field.py b/src/django_upgrade/fixers/postgres_float_range_field.py index 2a636cdd..795dec18 100644 --- a/src/django_upgrade/fixers/postgres_float_range_field.py +++ b/src/django_upgrade/fixers/postgres_float_range_field.py @@ -2,6 +2,7 @@ Replace FloatRangeField with DecimalRangeField: https://docs.djangoproject.com/en/2.2/releases/2.2/#features-deprecated-in-2-2 """ + from __future__ import annotations import ast diff --git a/src/django_upgrade/fixers/queryset_paginator.py b/src/django_upgrade/fixers/queryset_paginator.py index 8f0a98ca..349e69f1 100644 --- a/src/django_upgrade/fixers/queryset_paginator.py +++ b/src/django_upgrade/fixers/queryset_paginator.py @@ -2,6 +2,7 @@ Rewrite django.core.paginator’s alias QuerySetPaginator of Paginator: https://docs.djangoproject.com/en/2.2/releases/2.2/#features-deprecated-in-2-2 """ + from __future__ import annotations import ast diff --git a/src/django_upgrade/fixers/request_headers.py b/src/django_upgrade/fixers/request_headers.py index 4982df5f..275dd750 100644 --- a/src/django_upgrade/fixers/request_headers.py +++ b/src/django_upgrade/fixers/request_headers.py @@ -2,6 +2,7 @@ Update use of request.META to fetch headers to use request.headers https://docs.djangoproject.com/en/2.2/releases/2.2/#requests-and-responses """ + from __future__ import annotations import ast diff --git a/src/django_upgrade/fixers/settings_database_postgresql.py b/src/django_upgrade/fixers/settings_database_postgresql.py index edf9241f..4c8a69a5 100644 --- a/src/django_upgrade/fixers/settings_database_postgresql.py +++ b/src/django_upgrade/fixers/settings_database_postgresql.py @@ -3,6 +3,7 @@ to the new 'django.db.backends.postgresql'. https://docs.djangoproject.com/en/2.0/releases/2.0/#id1 """ + from __future__ import annotations import ast diff --git a/src/django_upgrade/fixers/settings_storages.py b/src/django_upgrade/fixers/settings_storages.py index e3c6d694..e5f1eef1 100644 --- a/src/django_upgrade/fixers/settings_storages.py +++ b/src/django_upgrade/fixers/settings_storages.py @@ -2,6 +2,7 @@ Merge DEFAULT_FILE_STORAGE and STATICFILES_STORAGE into new STORAGES setting: https://docs.djangoproject.com/en/4.2/releases/4.2/#custom-file-storages """ + from __future__ import annotations import ast diff --git a/src/django_upgrade/fixers/signal_providing_args.py b/src/django_upgrade/fixers/signal_providing_args.py index 39b500c1..506b3221 100644 --- a/src/django_upgrade/fixers/signal_providing_args.py +++ b/src/django_upgrade/fixers/signal_providing_args.py @@ -2,6 +2,7 @@ Remove the 'providing_args' argument from Signal(): https://docs.djangoproject.com/en/3.1/releases/3.1/#features-deprecated-in-3-1 """ + from __future__ import annotations import ast diff --git a/src/django_upgrade/fixers/test_http_headers.py b/src/django_upgrade/fixers/test_http_headers.py index 269a0138..235f0437 100644 --- a/src/django_upgrade/fixers/test_http_headers.py +++ b/src/django_upgrade/fixers/test_http_headers.py @@ -3,6 +3,7 @@ test Client and RequestFactory: https://docs.djangoproject.com/en/4.2/releases/4.2/#tests """ + from __future__ import annotations import ast diff --git a/src/django_upgrade/fixers/testcase_databases.py b/src/django_upgrade/fixers/testcase_databases.py index 34f902f3..f60815a8 100644 --- a/src/django_upgrade/fixers/testcase_databases.py +++ b/src/django_upgrade/fixers/testcase_databases.py @@ -2,6 +2,7 @@ Replace declarations of database support in test cases: https://docs.djangoproject.com/en/2.2/releases/2.2/#features-deprecated-in-2-2 """ + from __future__ import annotations import ast diff --git a/src/django_upgrade/fixers/timezone_fixedoffset.py b/src/django_upgrade/fixers/timezone_fixedoffset.py index bf739f4e..4c96cfcd 100644 --- a/src/django_upgrade/fixers/timezone_fixedoffset.py +++ b/src/django_upgrade/fixers/timezone_fixedoffset.py @@ -2,6 +2,7 @@ Rewrite django.utils.timezone.FixedOffset to datetime.timezone. https://docs.djangoproject.com/en/2.2/releases/2.2/#features-deprecated-in-2-2 """ + from __future__ import annotations import ast diff --git a/src/django_upgrade/fixers/use_l10n.py b/src/django_upgrade/fixers/use_l10n.py index be5674ac..a8404bd4 100644 --- a/src/django_upgrade/fixers/use_l10n.py +++ b/src/django_upgrade/fixers/use_l10n.py @@ -2,6 +2,7 @@ USE_L10N setting is deprecated: https://docs.djangoproject.com/en/4.0/releases/4.0/#localization """ + from __future__ import annotations import ast diff --git a/src/django_upgrade/fixers/utils_encoding.py b/src/django_upgrade/fixers/utils_encoding.py index e6b24be8..7b9fd410 100644 --- a/src/django_upgrade/fixers/utils_encoding.py +++ b/src/django_upgrade/fixers/utils_encoding.py @@ -2,6 +2,7 @@ Replace imports from django.utils.encoding: https://docs.djangoproject.com/en/3.0/releases/3.0/#django-utils-encoding-force-text-and-smart-text # noqa: E501 """ + from __future__ import annotations import ast diff --git a/src/django_upgrade/fixers/utils_http.py b/src/django_upgrade/fixers/utils_http.py index a84585be..c3d5e0d3 100644 --- a/src/django_upgrade/fixers/utils_http.py +++ b/src/django_upgrade/fixers/utils_http.py @@ -2,6 +2,7 @@ Replace imports from django.utils.http: https://docs.djangoproject.com/en/3.0/releases/3.0/#features-deprecated-in-3-0 """ + from __future__ import annotations import ast diff --git a/src/django_upgrade/fixers/utils_text.py b/src/django_upgrade/fixers/utils_text.py index f69c7e24..9326034a 100644 --- a/src/django_upgrade/fixers/utils_text.py +++ b/src/django_upgrade/fixers/utils_text.py @@ -2,6 +2,7 @@ Replace imports from django.utils.translation: https://docs.djangoproject.com/en/3.0/releases/3.0/#features-deprecated-in-3-0 """ + from __future__ import annotations import ast diff --git a/src/django_upgrade/fixers/utils_timezone.py b/src/django_upgrade/fixers/utils_timezone.py index 7286a5e7..2b8e033b 100644 --- a/src/django_upgrade/fixers/utils_timezone.py +++ b/src/django_upgrade/fixers/utils_timezone.py @@ -2,6 +2,7 @@ Replace django.utils.timezone.utc with datetime.timezone.utc https://docs.djangoproject.com/en/4.1/releases/4.1/#id2 """ + from __future__ import annotations import ast diff --git a/src/django_upgrade/fixers/utils_translation.py b/src/django_upgrade/fixers/utils_translation.py index 3a20d642..509fac70 100644 --- a/src/django_upgrade/fixers/utils_translation.py +++ b/src/django_upgrade/fixers/utils_translation.py @@ -2,6 +2,7 @@ Replace imports from django.utils.translation: https://docs.djangoproject.com/en/3.0/releases/3.0/#features-deprecated-in-3-0 """ + from __future__ import annotations import ast diff --git a/src/django_upgrade/fixers/versioned_branches.py b/src/django_upgrade/fixers/versioned_branches.py index 01502084..263e2efb 100644 --- a/src/django_upgrade/fixers/versioned_branches.py +++ b/src/django_upgrade/fixers/versioned_branches.py @@ -5,6 +5,7 @@ else: ... """ + from __future__ import annotations import ast