diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 169a72018..bdb051c09 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -3,7 +3,7 @@ default_language_version: python: python3 repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.2.0 + rev: v4.3.0 hooks: - id: trailing-whitespace - id: end-of-file-fixer @@ -16,6 +16,12 @@ repos: rev: v3.1.0 hooks: - id: reorder-python-imports + args: [--py37-plus, --add-import, 'from __future__ import annotations'] + - repo: https://github.com/asottile/pyupgrade + rev: v2.34.0 + hooks: + - id: pyupgrade + args: [--py38-plus] - repo: https://github.com/ambv/black rev: 22.3.0 hooks: @@ -26,7 +32,7 @@ repos: hooks: - id: flake8 - repo: https://github.com/pre-commit/mirrors-mypy - rev: v0.960 + rev: v0.961 hooks: - id: mypy files: ^dynaconf/ diff --git a/dynaconf/__init__.py b/dynaconf/__init__.py index a8cd25bf3..a99ce5f95 100644 --- a/dynaconf/__init__.py +++ b/dynaconf/__init__.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from dynaconf.base import LazySettings # noqa from dynaconf.constants import DEFAULT_SETTINGS_FILES from dynaconf.contrib import DjangoDynaconf # noqa diff --git a/dynaconf/base.py b/dynaconf/base.py index a501004c9..722298c77 100644 --- a/dynaconf/base.py +++ b/dynaconf/base.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import copy import glob import importlib @@ -66,7 +68,7 @@ def __init__(self, wrapped=None, **kwargs): self.__resolve_config_aliases(kwargs) compat_kwargs(kwargs) self._kwargs = kwargs - super(LazySettings, self).__init__() + super().__init__() if wrapped: if self._django_override: @@ -267,7 +269,7 @@ def __setattr__(self, name, value): """Allow `settings.FOO = 'value'` while keeping internal attrs.""" if name in RESERVED_ATTRS: - super(Settings, self).__setattr__(name, value) + super().__setattr__(name, value) else: self.set(name, value) @@ -275,7 +277,7 @@ def __delattr__(self, name): """stores reference in `_deleted` for proper error management""" self._deleted.add(name) if hasattr(self, name): - super(Settings, self).__delattr__(name) + super().__delattr__(name) def __contains__(self, item): """Respond to `item in settings`""" @@ -902,7 +904,7 @@ def set( self.store[key] = value self._deleted.discard(key) - super(Settings, self).__setattr__(key, value) + super().__setattr__(key, value) # set loader identifiers so cleaners know which keys to clean if loader_identifier and loader_identifier in self.loaded_by_loaders: @@ -1215,7 +1217,7 @@ def dynaconf(self): internal methods and attrs. """ - class AttrProxy(object): + class AttrProxy: def __init__(self, obj): self.obj = obj diff --git a/dynaconf/cli.py b/dynaconf/cli.py index c52f7b1ff..d8529e124 100644 --- a/dynaconf/cli.py +++ b/dynaconf/cli.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import importlib import io import os @@ -366,15 +368,14 @@ def init(ctx, fileformat, path, env, _vars, _secrets, wg, y, django): ignore_line = ".secrets.*" comment = "\n# Ignore dynaconf secret files\n" if not gitignore_path.exists(): - with io.open(str(gitignore_path), "w", encoding=ENC) as f: + with open(str(gitignore_path), "w", encoding=ENC) as f: f.writelines([comment, ignore_line, "\n"]) else: existing = ( - ignore_line - in io.open(str(gitignore_path), encoding=ENC).read() + ignore_line in open(str(gitignore_path), encoding=ENC).read() ) if not existing: # pragma: no cover - with io.open(str(gitignore_path), "a+", encoding=ENC) as f: + with open(str(gitignore_path), "a+", encoding=ENC) as f: f.writelines([comment, ignore_line, "\n"]) click.echo( diff --git a/dynaconf/constants.py b/dynaconf/constants.py index 14deae41f..625627304 100644 --- a/dynaconf/constants.py +++ b/dynaconf/constants.py @@ -1,4 +1,6 @@ # pragma: no cover +from __future__ import annotations + INI_EXTENSIONS = (".ini", ".conf", ".properties") TOML_EXTENSIONS = (".toml", ".tml") YAML_EXTENSIONS = (".yaml", ".yml") diff --git a/dynaconf/contrib/__init__.py b/dynaconf/contrib/__init__.py index 565ae2120..2c0279a49 100644 --- a/dynaconf/contrib/__init__.py +++ b/dynaconf/contrib/__init__.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from dynaconf.contrib.django_dynaconf_v2 import DjangoDynaconf # noqa from dynaconf.contrib.flask_dynaconf import DynaconfConfig # noqa from dynaconf.contrib.flask_dynaconf import FlaskDynaconf # noqa diff --git a/dynaconf/contrib/django_dynaconf_v2.py b/dynaconf/contrib/django_dynaconf_v2.py index 7886737ac..47d695e92 100644 --- a/dynaconf/contrib/django_dynaconf_v2.py +++ b/dynaconf/contrib/django_dynaconf_v2.py @@ -20,6 +20,8 @@ DJANGO_ALLOWED_HOSTS='["localhost"]' \ python manage.py runserver """ +from __future__ import annotations + import inspect import os import sys diff --git a/dynaconf/contrib/flask_dynaconf.py b/dynaconf/contrib/flask_dynaconf.py index 65f01b8b2..6ccd8504d 100644 --- a/dynaconf/contrib/flask_dynaconf.py +++ b/dynaconf/contrib/flask_dynaconf.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import warnings from collections import ChainMap from contextlib import suppress @@ -142,7 +144,7 @@ class DynaconfConfig(Config): def __init__(self, _settings, _app, *args, **kwargs): """perform the initial load""" - super(DynaconfConfig, self).__init__(*args, **kwargs) + super().__init__(*args, **kwargs) # Bring Dynaconf instance value to Flask Config Config.update(self, _settings.store) diff --git a/dynaconf/default_settings.py b/dynaconf/default_settings.py index 7fe59db8a..5c0d3e662 100644 --- a/dynaconf/default_settings.py +++ b/dynaconf/default_settings.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import importlib import os import sys diff --git a/dynaconf/loaders/__init__.py b/dynaconf/loaders/__init__.py index a9f9c31af..e18cb8434 100644 --- a/dynaconf/loaders/__init__.py +++ b/dynaconf/loaders/__init__.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import importlib import os @@ -266,7 +268,7 @@ def write(filename, data, env=None): loader_name = f"{filename.rpartition('.')[-1]}_loader" loader = globals().get(loader_name) if not loader: - raise IOError(f"{loader_name} cannot be found.") + raise OSError(f"{loader_name} cannot be found.") data = DynaBox(data, box_settings={}).to_dict() if loader is not py_loader and env and env not in data: diff --git a/dynaconf/loaders/base.py b/dynaconf/loaders/base.py index be34b2903..0826ee75d 100644 --- a/dynaconf/loaders/base.py +++ b/dynaconf/loaders/base.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import io import warnings @@ -75,7 +77,7 @@ def get_source_data(self, files): for source_file in files: if source_file.endswith(self.extensions): try: - with io.open( + with open( source_file, encoding=self.obj.get( "ENCODING_FOR_DYNACONF", "utf-8" @@ -85,7 +87,7 @@ def get_source_data(self, files): self.obj._loaded_files.append(source_file) if content: data[source_file] = content - except IOError as e: + except OSError as e: if ".local." not in source_file: warnings.warn( f"{self.identifier}_loader: {source_file} " diff --git a/dynaconf/loaders/env_loader.py b/dynaconf/loaders/env_loader.py index 61feb66b7..660bd271b 100644 --- a/dynaconf/loaders/env_loader.py +++ b/dynaconf/loaders/env_loader.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from os import environ from dynaconf.utils import missing diff --git a/dynaconf/loaders/ini_loader.py b/dynaconf/loaders/ini_loader.py index 7b8304269..c3b56fd36 100644 --- a/dynaconf/loaders/ini_loader.py +++ b/dynaconf/loaders/ini_loader.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import io from pathlib import Path @@ -51,7 +53,7 @@ def write(settings_path, settings_data, merge=True): """ settings_path = Path(settings_path) if settings_path.exists() and merge: # pragma: no cover - with io.open( + with open( str(settings_path), encoding=default_settings.ENCODING_FOR_DYNACONF ) as open_file: object_merge(ConfigObj(open_file).dict(), settings_data) diff --git a/dynaconf/loaders/json_loader.py b/dynaconf/loaders/json_loader.py index bfc81aaa1..72c1e340e 100644 --- a/dynaconf/loaders/json_loader.py +++ b/dynaconf/loaders/json_loader.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import io import json from pathlib import Path @@ -58,12 +60,12 @@ def write(settings_path, settings_data, merge=True): """ settings_path = Path(settings_path) if settings_path.exists() and merge: # pragma: no cover - with io.open( + with open( str(settings_path), encoding=default_settings.ENCODING_FOR_DYNACONF ) as open_file: object_merge(json.load(open_file), settings_data) - with io.open( + with open( str(settings_path), "w", encoding=default_settings.ENCODING_FOR_DYNACONF, diff --git a/dynaconf/loaders/py_loader.py b/dynaconf/loaders/py_loader.py index bc95c94fc..f29645971 100644 --- a/dynaconf/loaders/py_loader.py +++ b/dynaconf/loaders/py_loader.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import errno import importlib import inspect @@ -108,12 +110,12 @@ def import_from_filename(obj, filename, silent=False): # pragma: no cover mod._is_error = False mod._error = None try: - with io.open( + with open( _find_file(filename), encoding=default_settings.ENCODING_FOR_DYNACONF, ) as config_file: exec(compile(config_file.read(), filename, "exec"), mod.__dict__) - except IOError as e: + except OSError as e: e.strerror = ( f"py_loader: error loading file " f"({e.strerror} {filename})\n" ) @@ -136,7 +138,7 @@ def write(settings_path, settings_data, merge=True): existing = DynaconfDict() load(existing, str(settings_path)) object_merge(existing, settings_data) - with io.open( + with open( str(settings_path), "w", encoding=default_settings.ENCODING_FOR_DYNACONF, diff --git a/dynaconf/loaders/redis_loader.py b/dynaconf/loaders/redis_loader.py index b420a108b..1123cb092 100644 --- a/dynaconf/loaders/redis_loader.py +++ b/dynaconf/loaders/redis_loader.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from dynaconf.utils import build_env_list from dynaconf.utils import upperfy from dynaconf.utils.parse_conf import parse_conf_data diff --git a/dynaconf/loaders/toml_loader.py b/dynaconf/loaders/toml_loader.py index 8248957d6..372e0589e 100644 --- a/dynaconf/loaders/toml_loader.py +++ b/dynaconf/loaders/toml_loader.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import io from pathlib import Path @@ -44,12 +46,12 @@ def write(settings_path, settings_data, merge=True): """ settings_path = Path(settings_path) if settings_path.exists() and merge: # pragma: no cover - with io.open( + with open( str(settings_path), encoding=default_settings.ENCODING_FOR_DYNACONF ) as open_file: object_merge(toml.load(open_file), settings_data) - with io.open( + with open( str(settings_path), "w", encoding=default_settings.ENCODING_FOR_DYNACONF, diff --git a/dynaconf/loaders/vault_loader.py b/dynaconf/loaders/vault_loader.py index 44e9251c1..9408a5aa0 100644 --- a/dynaconf/loaders/vault_loader.py +++ b/dynaconf/loaders/vault_loader.py @@ -1,5 +1,7 @@ # docker run -e 'VAULT_DEV_ROOT_TOKEN_ID=myroot' -p 8200:8200 vault # pip install hvac +from __future__ import annotations + from dynaconf.utils import build_env_list from dynaconf.utils.parse_conf import parse_conf_data diff --git a/dynaconf/loaders/yaml_loader.py b/dynaconf/loaders/yaml_loader.py index fa63150e4..37b0b6c6b 100644 --- a/dynaconf/loaders/yaml_loader.py +++ b/dynaconf/loaders/yaml_loader.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import io from pathlib import Path from warnings import warn @@ -65,12 +67,12 @@ def write(settings_path, settings_data, merge=True): """ settings_path = Path(settings_path) if settings_path.exists() and merge: # pragma: no cover - with io.open( + with open( str(settings_path), encoding=default_settings.ENCODING_FOR_DYNACONF ) as open_file: object_merge(yaml.safe_load(open_file), settings_data) - with io.open( + with open( str(settings_path), "w", encoding=default_settings.ENCODING_FOR_DYNACONF, diff --git a/dynaconf/strategies/filtering.py b/dynaconf/strategies/filtering.py index 12b49a0cf..ef1f51ff9 100644 --- a/dynaconf/strategies/filtering.py +++ b/dynaconf/strategies/filtering.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from dynaconf.utils import upperfy @@ -5,7 +7,7 @@ class PrefixFilter: def __init__(self, prefix): if not isinstance(prefix, str): raise TypeError("`SETTINGS_FILE_PREFIX` must be str") - self.prefix = "{}_".format(upperfy(prefix)) + self.prefix = f"{upperfy(prefix)}_" def __call__(self, data): """Filter incoming data by prefix""" diff --git a/dynaconf/test_settings.py b/dynaconf/test_settings.py index 61e7638ee..3c43ec903 100644 --- a/dynaconf/test_settings.py +++ b/dynaconf/test_settings.py @@ -1,4 +1,6 @@ # pragma: no cover +from __future__ import annotations + TESTING = True LOADERS_FOR_DYNACONF = [ "dynaconf.loaders.env_loader", diff --git a/dynaconf/utils/__init__.py b/dynaconf/utils/__init__.py index 5ca60748f..e55ec14ad 100644 --- a/dynaconf/utils/__init__.py +++ b/dynaconf/utils/__init__.py @@ -5,13 +5,8 @@ from collections import defaultdict from json import JSONDecoder from typing import Any -from typing import Dict from typing import Iterator -from typing import List -from typing import Optional -from typing import Tuple from typing import TYPE_CHECKING -from typing import Union if TYPE_CHECKING: # pragma: no cover @@ -34,7 +29,7 @@ def object_merge( - old: Any, new: Any, unique: bool = False, full_path: List[str] = None + old: Any, new: Any, unique: bool = False, full_path: list[str] = None ) -> Any: """ Recursively merge two data structures, new is mutated in-place. @@ -86,8 +81,8 @@ def object_merge( def recursive_get( - obj: Union[DynaBox, Dict[str, int], Dict[str, Union[str, int]]], - names: Optional[List[str]], + obj: DynaBox | dict[str, int] | dict[str, str | int], + names: list[str] | None, ) -> Any: """Given a dot accessible object and a list of names `foo.bar.zaz` gets recursivelly all names one by one obj.foo.bar.zaz. @@ -102,7 +97,7 @@ def recursive_get( def handle_metavalues( - old: Union[DynaBox, Dict[str, int], Dict[str, Union[str, int]]], new: Any + old: DynaBox | dict[str, int] | dict[str, str | int], new: Any ) -> None: """Cleanup of MetaValues on new dict""" @@ -178,7 +173,7 @@ def __init__(self, *args, **kwargs): self._not_installed_warnings = [] self._validate_only = kwargs.pop("validate_only", None) self._validate_exclude = kwargs.pop("validate_exclude", None) - super(DynaconfDict, self).__init__(*args, **kwargs) + super().__init__(*args, **kwargs) def set(self, key: str, value: str, *args, **kwargs) -> None: self[key] = value @@ -208,7 +203,7 @@ def exists(self, key: str, **kwargs) -> bool: } -def compat_kwargs(kwargs: Dict[str, Any]) -> None: +def compat_kwargs(kwargs: dict[str, Any]) -> None: """To keep backwards compat change the kwargs to new names""" warn_deprecations(kwargs) for old, new in RENAMED_VARS.items(): @@ -230,7 +225,7 @@ def __bool__(self) -> bool: """Respond to boolean duck-typing.""" return False - def __eq__(self, other: Union[DynaBox, Missing]) -> bool: + def __eq__(self, other: DynaBox | Missing) -> bool: """Equality check for a singleton.""" return isinstance(other, self.__class__) @@ -249,7 +244,7 @@ def __repr__(self) -> str: missing = Missing() -def deduplicate(list_object: List[str]) -> List[str]: +def deduplicate(list_object: list[str]) -> list[str]: """Rebuild `list_object` removing duplicated and keeping order""" new = [] for item in list_object: @@ -269,8 +264,8 @@ def warn_deprecations(data: Any) -> None: def trimmed_split( - s: str, seps: Union[str, Tuple[str, str]] = (";", ",") -) -> List[str]: + s: str, seps: str | tuple[str, str] = (";", ",") +) -> list[str]: """Given a string s, split is by one of one of the seps.""" for sep in seps: if sep not in s: @@ -280,7 +275,7 @@ def trimmed_split( return [s] # raw un-splitted -def ensure_a_list(data: Any) -> Union[List[int], List[str]]: +def ensure_a_list(data: Any) -> list[int] | list[str]: """Ensure data is a list or wrap it in a list""" if not data: return [] @@ -292,9 +287,7 @@ def ensure_a_list(data: Any) -> Union[List[int], List[str]]: return [data] -def build_env_list( - obj: Union[Settings, LazySettings], env: Optional[str] -) -> List[str]: +def build_env_list(obj: Settings | LazySettings, env: str | None) -> list[str]: """Build env list for loaders to iterate. Arguments: @@ -355,7 +348,7 @@ def upperfy(key: str) -> str: return key.upper() -def multi_replace(text: str, patterns: Dict[str, str]) -> str: +def multi_replace(text: str, patterns: dict[str, str]) -> str: """Replaces multiple pairs in a string Arguments: @@ -372,7 +365,7 @@ def multi_replace(text: str, patterns: Dict[str, str]) -> str: def extract_json_objects( text: str, decoder: JSONDecoder = JSONDecoder() -) -> Iterator[Dict[str, Union[int, Dict[Any, Any]]]]: +) -> Iterator[dict[str, int | dict[Any, Any]]]: """Find JSON objects in text, and yield the decoded JSON data Does not attempt to look for JSON arrays, text, or other JSON types outside @@ -393,7 +386,7 @@ def extract_json_objects( def recursively_evaluate_lazy_format( - value: Any, settings: Union[Settings, LazySettings] + value: Any, settings: Settings | LazySettings ) -> Any: """Given a value as a data structure, traverse all its members to find Lazy values and evaluate it. diff --git a/dynaconf/utils/boxing.py b/dynaconf/utils/boxing.py index 9a30453d0..0ae93b8ee 100644 --- a/dynaconf/utils/boxing.py +++ b/dynaconf/utils/boxing.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import inspect from functools import wraps @@ -33,18 +35,18 @@ class DynaBox(Box): @evaluate_lazy_format def __getattr__(self, item, *args, **kwargs): try: - return super(DynaBox, self).__getattr__(item, *args, **kwargs) + return super().__getattr__(item, *args, **kwargs) except (AttributeError, KeyError): n_item = item.lower() if item.isupper() else upperfy(item) - return super(DynaBox, self).__getattr__(n_item, *args, **kwargs) + return super().__getattr__(n_item, *args, **kwargs) @evaluate_lazy_format def __getitem__(self, item, *args, **kwargs): try: - return super(DynaBox, self).__getitem__(item, *args, **kwargs) + return super().__getitem__(item, *args, **kwargs) except (AttributeError, KeyError): n_item = item.lower() if item.isupper() else upperfy(item) - return super(DynaBox, self).__getitem__(n_item, *args, **kwargs) + return super().__getitem__(n_item, *args, **kwargs) def __copy__(self): return self.__class__( @@ -69,7 +71,7 @@ def _case_insensitive_get(self, item, default=None): def get(self, item, default=None, *args, **kwargs): if item not in self: # toggle case item = item.lower() if item.isupper() else upperfy(item) - value = super(DynaBox, self).get(item, empty, *args, **kwargs) + value = super().get(item, empty, *args, **kwargs) if value is empty: # see Issue: #486 return self._case_insensitive_get(item, default) diff --git a/dynaconf/utils/files.py b/dynaconf/utils/files.py index 3331db5af..df6e5b66a 100644 --- a/dynaconf/utils/files.py +++ b/dynaconf/utils/files.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import inspect import io import os @@ -10,7 +12,7 @@ def _walk_to_root(path, break_at=None): Directories starting from the given directory up to the root or break_at """ if not os.path.exists(path): # pragma: no cover - raise IOError("Starting path not found") + raise OSError("Starting path not found") if os.path.isfile(path): # pragma: no cover path = os.path.dirname(path) @@ -84,7 +86,7 @@ def find_file(filename=".env", project_root=None, skip_files=None, **kwargs): def read_file(path, **kwargs): content = "" - with io.open(path, **kwargs) as open_file: + with open(path, **kwargs) as open_file: content = open_file.read().strip() return content diff --git a/dynaconf/utils/functional.py b/dynaconf/utils/functional.py index 147d26a7e..c9a93afc8 100644 --- a/dynaconf/utils/functional.py +++ b/dynaconf/utils/functional.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import copy import operator diff --git a/dynaconf/utils/parse_conf.py b/dynaconf/utils/parse_conf.py index 851664361..902ba2725 100644 --- a/dynaconf/utils/parse_conf.py +++ b/dynaconf/utils/parse_conf.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import json import os import re diff --git a/dynaconf/validator.py b/dynaconf/validator.py index 78c06c787..f3c581d46 100644 --- a/dynaconf/validator.py +++ b/dynaconf/validator.py @@ -5,11 +5,7 @@ from types import MappingProxyType from typing import Any from typing import Callable -from typing import Dict -from typing import List -from typing import Optional from typing import Sequence -from typing import Union from dynaconf import validator_conditions from dynaconf.utils import ensure_a_list @@ -105,16 +101,16 @@ class Validator: def __init__( self, *names: str, - must_exist: Optional[bool] = None, - required: Optional[bool] = None, # alias for `must_exist` - condition: Optional[Callable[[Any], bool]] = None, - when: Optional[Validator] = None, - env: Optional[Union[str, Sequence[str]]] = None, - messages: Optional[Dict[str, str]] = None, - cast: Optional[Callable[[Any], Any]] = None, - default: Optional[Union[Any, Callable[[Any, Validator], Any]]] = empty, - description: Optional[str] = None, - apply_default_on_none: Optional[bool] = False, + must_exist: bool | None = None, + required: bool | None = None, # alias for `must_exist` + condition: Callable[[Any], bool] | None = None, + when: Validator | None = None, + env: str | Sequence[str] | None = None, + messages: dict[str, str] | None = None, + cast: Callable[[Any], Any] | None = None, + default: Any | Callable[[Any, Validator], Any] | None = empty, + description: str | None = None, + apply_default_on_none: bool | None = False, **operations: Any, ) -> None: # Copy immutable MappingProxyType as a mutable dict @@ -136,7 +132,7 @@ def __init__( self.operations = operations self.default = default self.description = description - self.envs: Optional[Sequence[str]] = None + self.envs: Sequence[str] | None = None self.apply_default_on_none = apply_default_on_none if isinstance(env, str): @@ -169,8 +165,8 @@ def __eq__(self, other: object) -> bool: def validate( self, settings: Any, - only: Optional[Union[str, Sequence]] = None, - exclude: Optional[Union[str, Sequence]] = None, + only: str | Sequence | None = None, + exclude: str | Sequence | None = None, only_current_env: bool = False, ) -> None: """Raise ValidationError if invalid""" @@ -224,9 +220,9 @@ def validate( def _validate_items( self, settings: Any, - env: Optional[str] = None, - only: Optional[Union[str, Sequence]] = None, - exclude: Optional[Union[str, Sequence]] = None, + env: str | None = None, + only: str | Sequence | None = None, + exclude: str | Sequence | None = None, ) -> None: env = env or settings.current_env for name in self.names: @@ -317,8 +313,8 @@ def __init__( def validate( self, settings: Any, - only: Optional[Union[str, Sequence]] = None, - exclude: Optional[Union[str, Sequence]] = None, + only: str | Sequence | None = None, + exclude: str | Sequence | None = None, only_current_env: bool = False, ) -> None: # pragma: no cover raise NotImplementedError( @@ -332,8 +328,8 @@ class OrValidator(CombinedValidator): def validate( self, settings: Any, - only: Optional[Union[str, Sequence]] = None, - exclude: Optional[Union[str, Sequence]] = None, + only: str | Sequence | None = None, + exclude: str | Sequence | None = None, only_current_env: bool = False, ) -> None: """Ensure at least one of the validators are valid""" @@ -367,8 +363,8 @@ class AndValidator(CombinedValidator): def validate( self, settings: Any, - only: Optional[Union[str, Sequence]] = None, - exclude: Optional[Union[str, Sequence]] = None, + only: str | Sequence | None = None, + exclude: str | Sequence | None = None, only_current_env: bool = False, ) -> None: """Ensure both the validators are valid""" @@ -399,7 +395,7 @@ class ValidatorList(list): def __init__( self, settings: Any, - validators: Optional[Sequence[Validator]] = None, + validators: Sequence[Validator] | None = None, *args: Validator, **kwargs: Any, ) -> None: @@ -407,11 +403,11 @@ def __init__( args = list(args) + list(validators) # type: ignore self._only = kwargs.pop("validate_only", None) self._exclude = kwargs.pop("validate_exclude", None) - super(ValidatorList, self).__init__(args, **kwargs) # type: ignore + super().__init__(args, **kwargs) # type: ignore self.settings = settings def register(self, *args: Validator, **kwargs: Validator): - validators: List[Validator] = list( + validators: list[Validator] = list( chain.from_iterable(kwargs.values()) # type: ignore ) validators.extend(args) @@ -419,12 +415,10 @@ def register(self, *args: Validator, **kwargs: Validator): if validator and validator not in self: self.append(validator) - def descriptions( - self, flat: bool = False - ) -> Dict[str, Union[str, List[str]]]: + def descriptions(self, flat: bool = False) -> dict[str, str | list[str]]: if flat: - descriptions: Dict[str, Union[str, List[str]]] = {} + descriptions: dict[str, str | list[str]] = {} else: descriptions = defaultdict(list) @@ -442,8 +436,8 @@ def descriptions( def validate( self, - only: Optional[Union[str, Sequence]] = None, - exclude: Optional[Union[str, Sequence]] = None, + only: str | Sequence | None = None, + exclude: str | Sequence | None = None, only_current_env: bool = False, ) -> None: for validator in self: @@ -456,8 +450,8 @@ def validate( def validate_all( self, - only: Optional[Union[str, Sequence]] = None, - exclude: Optional[Union[str, Sequence]] = None, + only: str | Sequence | None = None, + exclude: str | Sequence | None = None, only_current_env: bool = False, ) -> None: errors = [] diff --git a/dynaconf/validator_conditions.py b/dynaconf/validator_conditions.py index cb1c3f513..c9a9351eb 100644 --- a/dynaconf/validator_conditions.py +++ b/dynaconf/validator_conditions.py @@ -2,6 +2,7 @@ """ Implement basic assertions to be used in assertion action """ +from __future__ import annotations def eq(value, other): diff --git a/example/-m_case/module/__main__.py b/example/-m_case/module/__main__.py index a95681883..15153450a 100644 --- a/example/-m_case/module/__main__.py +++ b/example/-m_case/module/__main__.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from dynaconf import Dynaconf settings = Dynaconf( diff --git a/example/app/app.py b/example/app/app.py index 5db582b62..12733be18 100644 --- a/example/app/app.py +++ b/example/app/app.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from dynaconf import settings print(settings.MYSQL_HOST) # noqa diff --git a/example/app/mysettings.py b/example/app/mysettings.py index 5e50c7253..72e90a7df 100644 --- a/example/app/mysettings.py +++ b/example/app/mysettings.py @@ -1,3 +1,5 @@ +from __future__ import annotations + EXAMPLE = True MYSQL_HOST = "server.com" WORKS = "app" diff --git a/example/app_with_dotenv/app.py b/example/app_with_dotenv/app.py index fc53ccc81..fa1d5e43d 100644 --- a/example/app_with_dotenv/app.py +++ b/example/app_with_dotenv/app.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from dynaconf import settings print(settings.MYSQL_HOST) # noqa diff --git a/example/apply_default_on_none/app.py b/example/apply_default_on_none/app.py index 5176af8e3..e3c42a015 100644 --- a/example/apply_default_on_none/app.py +++ b/example/apply_default_on_none/app.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from dynaconf import Dynaconf from dynaconf import Validator diff --git a/example/common-encoding/program.py b/example/common-encoding/program.py index 69838d60b..a88350ea9 100644 --- a/example/common-encoding/program.py +++ b/example/common-encoding/program.py @@ -1,4 +1,6 @@ # Take as example a program which connects to a database +from __future__ import annotations + import io import os @@ -29,13 +31,13 @@ def connect(server, port, username, password): print("#" * 79) print("\n* The settings are defined in .toml files\n") print("$ cat settings.toml") -with io.open( +with open( settings.find_file("settings.toml"), encoding=os.environ.get("ENCODING_FOR_DYNACONF"), ) as settings_file: print(settings_file.read()) print("$ cat .secrets.toml") -with io.open( +with open( settings.find_file(".secrets.toml"), encoding=os.environ.get("ENCODING_FOR_DYNACONF"), ) as secrets_file: diff --git a/example/common/program.py b/example/common/program.py index 1b4b5f117..5dcb10825 100644 --- a/example/common/program.py +++ b/example/common/program.py @@ -1,4 +1,5 @@ # Take as example a program which connects to a database +from __future__ import annotations def connect(server, port, username, password): diff --git a/example/compat.py b/example/compat.py index 6d4053b14..72bfcae86 100644 --- a/example/compat.py +++ b/example/compat.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import os import tempfile diff --git a/example/configure/app.py b/example/configure/app.py index ced68e86b..047824878 100644 --- a/example/configure/app.py +++ b/example/configure/app.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from dynaconf import settings settings.configure(settings_module="/tmp/configure_test/settings.py") diff --git a/example/custom_loader/app.py b/example/custom_loader/app.py index ff64d5fbd..c22f39483 100644 --- a/example/custom_loader/app.py +++ b/example/custom_loader/app.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from dynaconf import settings with open(settings.find_file("settings.sff")) as settings_file: diff --git a/example/custom_loader/my_custom_loader/sff_loader.py b/example/custom_loader/my_custom_loader/sff_loader.py index b8d1cefc1..89b78517d 100644 --- a/example/custom_loader/my_custom_loader/sff_loader.py +++ b/example/custom_loader/my_custom_loader/sff_loader.py @@ -1,5 +1,6 @@ # In order to have multiple envs support use BaseLoader # Take a look in dynaconf/loaders/json_loader.py +from __future__ import annotations def load(obj, env=None, silent=True, key=None, filename=None): diff --git a/example/debug/app.py b/example/debug/app.py index 09c1b87c4..8ad7bcbd1 100644 --- a/example/debug/app.py +++ b/example/debug/app.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from dynaconf import Dynaconf settings = Dynaconf(settings_file="settings.toml") diff --git a/example/django_example/foo/a_plugin_folder/dynaconf_hooks.py b/example/django_example/foo/a_plugin_folder/dynaconf_hooks.py index a042fd42d..3bd8b90af 100644 --- a/example/django_example/foo/a_plugin_folder/dynaconf_hooks.py +++ b/example/django_example/foo/a_plugin_folder/dynaconf_hooks.py @@ -1,3 +1,6 @@ +from __future__ import annotations + + def post(settings): data = {"dynaconf_merge": True} if settings.get("ADD_BEATLES") is True: diff --git a/example/django_example/foo/a_plugin_folder/settings.py b/example/django_example/foo/a_plugin_folder/settings.py index 7810cdad7..38139d90d 100644 --- a/example/django_example/foo/a_plugin_folder/settings.py +++ b/example/django_example/foo/a_plugin_folder/settings.py @@ -1 +1,3 @@ +from __future__ import annotations + BANDS = ["Metallica", "Black Sabbath", "Iron Maiden"] diff --git a/example/django_example/foo/dynaconf_hooks.py b/example/django_example/foo/dynaconf_hooks.py index 1ba48036b..d64a94764 100644 --- a/example/django_example/foo/dynaconf_hooks.py +++ b/example/django_example/foo/dynaconf_hooks.py @@ -1,2 +1,5 @@ +from __future__ import annotations + + def post(settings): return {"HOOK_ON_DJANGO_APP": True} diff --git a/example/django_example/foo/settings.py b/example/django_example/foo/settings.py index 6c276f3f6..8f8c262a3 100644 --- a/example/django_example/foo/settings.py +++ b/example/django_example/foo/settings.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import os import sys diff --git a/example/django_example/foo/urls.py b/example/django_example/foo/urls.py index 55e6d68a6..99d185c15 100644 --- a/example/django_example/foo/urls.py +++ b/example/django_example/foo/urls.py @@ -13,6 +13,8 @@ 1. Import the include() function: from django.urls import include, path 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) """ +from __future__ import annotations + from django.conf import settings from django.contrib import admin from django.urls import include diff --git a/example/django_example/foo/wsgi.py b/example/django_example/foo/wsgi.py index 45625459d..f2fc605d0 100644 --- a/example/django_example/foo/wsgi.py +++ b/example/django_example/foo/wsgi.py @@ -6,6 +6,8 @@ For more information on this file, see https://docs.djangoproject.com/en/2.0/howto/deployment/wsgi/ """ +from __future__ import annotations + import os from django.core.wsgi import get_wsgi_application diff --git a/example/django_example/manage.py b/example/django_example/manage.py index db3dbcdf2..9624fc0ae 100755 --- a/example/django_example/manage.py +++ b/example/django_example/manage.py @@ -1,4 +1,6 @@ #!/usr/bin/env python +from __future__ import annotations + import os import sys diff --git a/example/django_example/polls/admin.py b/example/django_example/polls/admin.py index 8c38f3f3d..07d205914 100644 --- a/example/django_example/polls/admin.py +++ b/example/django_example/polls/admin.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from django.contrib import admin # Register your models here. diff --git a/example/django_example/polls/apps.py b/example/django_example/polls/apps.py index 292f00d13..654d697e2 100644 --- a/example/django_example/polls/apps.py +++ b/example/django_example/polls/apps.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from django.apps import AppConfig diff --git a/example/django_example/polls/models.py b/example/django_example/polls/models.py index 71a836239..48c5c6ae5 100644 --- a/example/django_example/polls/models.py +++ b/example/django_example/polls/models.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from django.db import models # Create your models here. diff --git a/example/django_example/polls/tests.py b/example/django_example/polls/tests.py index 6f6437435..94290bfad 100644 --- a/example/django_example/polls/tests.py +++ b/example/django_example/polls/tests.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from django.conf import settings from django.test import TestCase from django.test.utils import override_settings diff --git a/example/django_example/polls/urls.py b/example/django_example/polls/urls.py index 7ece5c998..a0994e6cf 100644 --- a/example/django_example/polls/urls.py +++ b/example/django_example/polls/urls.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from django.urls import path from . import views diff --git a/example/django_example/polls/views.py b/example/django_example/polls/views.py index 48b88cdf9..cee1ec262 100644 --- a/example/django_example/polls/views.py +++ b/example/django_example/polls/views.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from django.conf import settings from django.http import HttpResponse diff --git a/example/django_example/pulpsettings.py b/example/django_example/pulpsettings.py index 34052454e..269dd6810 100644 --- a/example/django_example/pulpsettings.py +++ b/example/django_example/pulpsettings.py @@ -1,3 +1,5 @@ +from __future__ import annotations + REST_FRAMEWORK__DEFAULT_AUTHENTICATION_CLASSES = ( "rest_framework.authentication.SessionAuthentication", "pulpcore.app.authentication.PulpRemoteUserAuthentication", diff --git a/example/django_example/standalone_script.py b/example/django_example/standalone_script.py index e8a127f49..941408aed 100644 --- a/example/django_example/standalone_script.py +++ b/example/django_example/standalone_script.py @@ -1,4 +1,6 @@ # You should start your standalone scripts with this: +from __future__ import annotations + from django.conf import settings # This `DYNACONF.configure()` line may be useful in some cases diff --git a/example/django_example_compat/foo/settings.py b/example/django_example_compat/foo/settings.py index 0421b7e92..473e0d68f 100644 --- a/example/django_example_compat/foo/settings.py +++ b/example/django_example_compat/foo/settings.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import os # Where is all the Django's settings? diff --git a/example/django_example_compat/foo/urls.py b/example/django_example_compat/foo/urls.py index 3931d8b56..3b0cd348b 100644 --- a/example/django_example_compat/foo/urls.py +++ b/example/django_example_compat/foo/urls.py @@ -13,6 +13,8 @@ 1. Import the include() function: from django.urls import include, path 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) """ +from __future__ import annotations + from django.contrib import admin from django.urls import include from django.urls import path diff --git a/example/django_example_compat/foo/wsgi.py b/example/django_example_compat/foo/wsgi.py index 45625459d..f2fc605d0 100644 --- a/example/django_example_compat/foo/wsgi.py +++ b/example/django_example_compat/foo/wsgi.py @@ -6,6 +6,8 @@ For more information on this file, see https://docs.djangoproject.com/en/2.0/howto/deployment/wsgi/ """ +from __future__ import annotations + import os from django.core.wsgi import get_wsgi_application diff --git a/example/django_example_compat/includes/plugin_settings.py b/example/django_example_compat/includes/plugin_settings.py index 9574b06bd..d90a21a5f 100644 --- a/example/django_example_compat/includes/plugin_settings.py +++ b/example/django_example_compat/includes/plugin_settings.py @@ -1,2 +1,4 @@ +from __future__ import annotations + PLUGIN_ENABLED = True PLUGIN_LIST = ["plugin1", "plugin2"] diff --git a/example/django_example_compat/manage.py b/example/django_example_compat/manage.py index db3dbcdf2..9624fc0ae 100755 --- a/example/django_example_compat/manage.py +++ b/example/django_example_compat/manage.py @@ -1,4 +1,6 @@ #!/usr/bin/env python +from __future__ import annotations + import os import sys diff --git a/example/django_example_compat/polls/admin.py b/example/django_example_compat/polls/admin.py index 8c38f3f3d..07d205914 100644 --- a/example/django_example_compat/polls/admin.py +++ b/example/django_example_compat/polls/admin.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from django.contrib import admin # Register your models here. diff --git a/example/django_example_compat/polls/apps.py b/example/django_example_compat/polls/apps.py index 292f00d13..654d697e2 100644 --- a/example/django_example_compat/polls/apps.py +++ b/example/django_example_compat/polls/apps.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from django.apps import AppConfig diff --git a/example/django_example_compat/polls/models.py b/example/django_example_compat/polls/models.py index 71a836239..48c5c6ae5 100644 --- a/example/django_example_compat/polls/models.py +++ b/example/django_example_compat/polls/models.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from django.db import models # Create your models here. diff --git a/example/django_example_compat/polls/tests.py b/example/django_example_compat/polls/tests.py index a891bddaa..52306a6b0 100644 --- a/example/django_example_compat/polls/tests.py +++ b/example/django_example_compat/polls/tests.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from django.conf import settings from django.test import TestCase diff --git a/example/django_example_compat/polls/urls.py b/example/django_example_compat/polls/urls.py index 7ece5c998..a0994e6cf 100644 --- a/example/django_example_compat/polls/urls.py +++ b/example/django_example_compat/polls/urls.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from django.urls import path from . import views diff --git a/example/django_example_compat/polls/views.py b/example/django_example_compat/polls/views.py index 48b88cdf9..cee1ec262 100644 --- a/example/django_example_compat/polls/views.py +++ b/example/django_example_compat/polls/views.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from django.conf import settings from django.http import HttpResponse diff --git a/example/django_example_compat/standalone_script.py b/example/django_example_compat/standalone_script.py index e8a127f49..941408aed 100644 --- a/example/django_example_compat/standalone_script.py +++ b/example/django_example_compat/standalone_script.py @@ -1,4 +1,6 @@ # You should start your standalone scripts with this: +from __future__ import annotations + from django.conf import settings # This `DYNACONF.configure()` line may be useful in some cases diff --git a/example/django_pure/foo/settings.py b/example/django_pure/foo/settings.py index cd2f1eaa8..f1281ada6 100644 --- a/example/django_pure/foo/settings.py +++ b/example/django_pure/foo/settings.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import os # Where is all the Django's settings? diff --git a/example/django_pure/foo/urls.py b/example/django_pure/foo/urls.py index 55e6d68a6..99d185c15 100644 --- a/example/django_pure/foo/urls.py +++ b/example/django_pure/foo/urls.py @@ -13,6 +13,8 @@ 1. Import the include() function: from django.urls import include, path 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) """ +from __future__ import annotations + from django.conf import settings from django.contrib import admin from django.urls import include diff --git a/example/django_pure/foo/wsgi.py b/example/django_pure/foo/wsgi.py index 45625459d..f2fc605d0 100644 --- a/example/django_pure/foo/wsgi.py +++ b/example/django_pure/foo/wsgi.py @@ -6,6 +6,8 @@ For more information on this file, see https://docs.djangoproject.com/en/2.0/howto/deployment/wsgi/ """ +from __future__ import annotations + import os from django.core.wsgi import get_wsgi_application diff --git a/example/django_pure/manage.py b/example/django_pure/manage.py index db3dbcdf2..9624fc0ae 100755 --- a/example/django_pure/manage.py +++ b/example/django_pure/manage.py @@ -1,4 +1,6 @@ #!/usr/bin/env python +from __future__ import annotations + import os import sys diff --git a/example/django_pure/polls/admin.py b/example/django_pure/polls/admin.py index 8c38f3f3d..07d205914 100644 --- a/example/django_pure/polls/admin.py +++ b/example/django_pure/polls/admin.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from django.contrib import admin # Register your models here. diff --git a/example/django_pure/polls/apps.py b/example/django_pure/polls/apps.py index 292f00d13..654d697e2 100644 --- a/example/django_pure/polls/apps.py +++ b/example/django_pure/polls/apps.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from django.apps import AppConfig diff --git a/example/django_pure/polls/models.py b/example/django_pure/polls/models.py index 71a836239..48c5c6ae5 100644 --- a/example/django_pure/polls/models.py +++ b/example/django_pure/polls/models.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from django.db import models # Create your models here. diff --git a/example/django_pure/polls/tests.py b/example/django_pure/polls/tests.py index b3c912cf2..b097a3d48 100644 --- a/example/django_pure/polls/tests.py +++ b/example/django_pure/polls/tests.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from django.conf import settings from django.test import TestCase from django.test.utils import override_settings diff --git a/example/django_pure/polls/urls.py b/example/django_pure/polls/urls.py index 7ece5c998..a0994e6cf 100644 --- a/example/django_pure/polls/urls.py +++ b/example/django_pure/polls/urls.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from django.urls import path from . import views diff --git a/example/django_pure/polls/views.py b/example/django_pure/polls/views.py index 75bd1087d..5a20c2f61 100644 --- a/example/django_pure/polls/views.py +++ b/example/django_pure/polls/views.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from django.conf import settings from django.http import HttpResponse diff --git a/example/django_pure/standalone_script.py b/example/django_pure/standalone_script.py index e8a127f49..941408aed 100644 --- a/example/django_pure/standalone_script.py +++ b/example/django_pure/standalone_script.py @@ -1,4 +1,6 @@ # You should start your standalone scripts with this: +from __future__ import annotations + from django.conf import settings # This `DYNACONF.configure()` line may be useful in some cases diff --git a/example/django_pytest/app/admin.py b/example/django_pytest/app/admin.py index 8c38f3f3d..07d205914 100644 --- a/example/django_pytest/app/admin.py +++ b/example/django_pytest/app/admin.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from django.contrib import admin # Register your models here. diff --git a/example/django_pytest/app/apps.py b/example/django_pytest/app/apps.py index 200c5984c..0900cd9ae 100644 --- a/example/django_pytest/app/apps.py +++ b/example/django_pytest/app/apps.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from django.apps import AppConfig diff --git a/example/django_pytest/app/models.py b/example/django_pytest/app/models.py index 71a836239..48c5c6ae5 100644 --- a/example/django_pytest/app/models.py +++ b/example/django_pytest/app/models.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from django.db import models # Create your models here. diff --git a/example/django_pytest/app/tests/conftest.py b/example/django_pytest/app/tests/conftest.py index 16e104e5d..758795ee5 100644 --- a/example/django_pytest/app/tests/conftest.py +++ b/example/django_pytest/app/tests/conftest.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import pytest from django.core.management import call_command diff --git a/example/django_pytest/app/tests/test_app.py b/example/django_pytest/app/tests/test_app.py index ce7f3e912..04d5671fb 100644 --- a/example/django_pytest/app/tests/test_app.py +++ b/example/django_pytest/app/tests/test_app.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import django django.setup() # noqa diff --git a/example/django_pytest/app/urls.py b/example/django_pytest/app/urls.py index c1e3a7427..f28e8703d 100644 --- a/example/django_pytest/app/urls.py +++ b/example/django_pytest/app/urls.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from app import views from django.urls import include from django.urls import path diff --git a/example/django_pytest/app/views.py b/example/django_pytest/app/views.py index d53f9d5bb..c14ceaa82 100644 --- a/example/django_pytest/app/views.py +++ b/example/django_pytest/app/views.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from django.views.generic import TemplateView diff --git a/example/django_pytest/manage.py b/example/django_pytest/manage.py index f522e0072..bab73739f 100755 --- a/example/django_pytest/manage.py +++ b/example/django_pytest/manage.py @@ -1,4 +1,6 @@ #!/usr/bin/env python +from __future__ import annotations + import os import sys diff --git a/example/django_pytest/project/settings.py b/example/django_pytest/project/settings.py index f75d8228a..9b1c38cb6 100644 --- a/example/django_pytest/project/settings.py +++ b/example/django_pytest/project/settings.py @@ -3,6 +3,8 @@ https://docs.djangoproject.com/en/1.11/ref/settings/ https://docs.djangoproject.com/en/1.11/howto/deployment/checklist/ """ +from __future__ import annotations + import os from collections import OrderedDict diff --git a/example/django_pytest/project/urls.py b/example/django_pytest/project/urls.py index b32ab9d8f..744b6d25d 100644 --- a/example/django_pytest/project/urls.py +++ b/example/django_pytest/project/urls.py @@ -1,4 +1,6 @@ # https://docs.djangoproject.com/en/1.10/topics/http/urls/ +from __future__ import annotations + from django.contrib import admin from django.urls import include from django.urls import path diff --git a/example/django_pytest/project/wsgi.py b/example/django_pytest/project/wsgi.py index 1f6156f21..92f736667 100644 --- a/example/django_pytest/project/wsgi.py +++ b/example/django_pytest/project/wsgi.py @@ -1,4 +1,6 @@ # https://docs.djangoproject.com/en/1.10/howto/deployment/wsgi/ +from __future__ import annotations + import os from django.core.wsgi import get_wsgi_application diff --git a/example/django_pytest_pure/app/admin.py b/example/django_pytest_pure/app/admin.py index 8c38f3f3d..07d205914 100644 --- a/example/django_pytest_pure/app/admin.py +++ b/example/django_pytest_pure/app/admin.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from django.contrib import admin # Register your models here. diff --git a/example/django_pytest_pure/app/apps.py b/example/django_pytest_pure/app/apps.py index 200c5984c..0900cd9ae 100644 --- a/example/django_pytest_pure/app/apps.py +++ b/example/django_pytest_pure/app/apps.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from django.apps import AppConfig diff --git a/example/django_pytest_pure/app/models.py b/example/django_pytest_pure/app/models.py index 71a836239..48c5c6ae5 100644 --- a/example/django_pytest_pure/app/models.py +++ b/example/django_pytest_pure/app/models.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from django.db import models # Create your models here. diff --git a/example/django_pytest_pure/app/tests/conftest.py b/example/django_pytest_pure/app/tests/conftest.py index 7803503f4..74f76de11 100644 --- a/example/django_pytest_pure/app/tests/conftest.py +++ b/example/django_pytest_pure/app/tests/conftest.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import pytest from django.core.management import call_command diff --git a/example/django_pytest_pure/app/tests/test_app.py b/example/django_pytest_pure/app/tests/test_app.py index b7f803aac..50525deb6 100644 --- a/example/django_pytest_pure/app/tests/test_app.py +++ b/example/django_pytest_pure/app/tests/test_app.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import django django.setup() # noqa diff --git a/example/django_pytest_pure/app/urls.py b/example/django_pytest_pure/app/urls.py index c1e3a7427..f28e8703d 100644 --- a/example/django_pytest_pure/app/urls.py +++ b/example/django_pytest_pure/app/urls.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from app import views from django.urls import include from django.urls import path diff --git a/example/django_pytest_pure/app/views.py b/example/django_pytest_pure/app/views.py index d53f9d5bb..c14ceaa82 100644 --- a/example/django_pytest_pure/app/views.py +++ b/example/django_pytest_pure/app/views.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from django.views.generic import TemplateView diff --git a/example/django_pytest_pure/manage.py b/example/django_pytest_pure/manage.py index f522e0072..bab73739f 100755 --- a/example/django_pytest_pure/manage.py +++ b/example/django_pytest_pure/manage.py @@ -1,4 +1,6 @@ #!/usr/bin/env python +from __future__ import annotations + import os import sys diff --git a/example/django_pytest_pure/project/settings.py b/example/django_pytest_pure/project/settings.py index 27312417c..0b027a9ee 100644 --- a/example/django_pytest_pure/project/settings.py +++ b/example/django_pytest_pure/project/settings.py @@ -3,6 +3,8 @@ https://docs.djangoproject.com/en/1.11/ref/settings/ https://docs.djangoproject.com/en/1.11/howto/deployment/checklist/ """ +from __future__ import annotations + import os from collections import OrderedDict diff --git a/example/django_pytest_pure/project/urls.py b/example/django_pytest_pure/project/urls.py index b32ab9d8f..744b6d25d 100644 --- a/example/django_pytest_pure/project/urls.py +++ b/example/django_pytest_pure/project/urls.py @@ -1,4 +1,6 @@ # https://docs.djangoproject.com/en/1.10/topics/http/urls/ +from __future__ import annotations + from django.contrib import admin from django.urls import include from django.urls import path diff --git a/example/django_pytest_pure/project/wsgi.py b/example/django_pytest_pure/project/wsgi.py index 1f6156f21..92f736667 100644 --- a/example/django_pytest_pure/project/wsgi.py +++ b/example/django_pytest_pure/project/wsgi.py @@ -1,4 +1,6 @@ # https://docs.djangoproject.com/en/1.10/howto/deployment/wsgi/ +from __future__ import annotations + import os from django.core.wsgi import get_wsgi_application diff --git a/example/dotenv_loaded_if_enabled/app.py b/example/dotenv_loaded_if_enabled/app.py index f7be3613d..a89485d53 100644 --- a/example/dotenv_loaded_if_enabled/app.py +++ b/example/dotenv_loaded_if_enabled/app.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from dynaconf import Dynaconf settings = Dynaconf(settings_file="settings.toml", load_dotenv=True) diff --git a/example/dotenv_not_loaded_by_default/app.py b/example/dotenv_not_loaded_by_default/app.py index 656319fec..0180d1bc5 100644 --- a/example/dotenv_not_loaded_by_default/app.py +++ b/example/dotenv_not_loaded_by_default/app.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from dynaconf import Dynaconf settings = Dynaconf(settings_file="settings.toml") diff --git a/example/dummy_flask_extension/__init__.py b/example/dummy_flask_extension/__init__.py index 4c2731f21..03095263b 100644 --- a/example/dummy_flask_extension/__init__.py +++ b/example/dummy_flask_extension/__init__.py @@ -1,4 +1,7 @@ -class DummyExtensionType(object): +from __future__ import annotations + + +class DummyExtensionType: def __init__(self, app=None): self.app = app if app is not None: diff --git a/example/dummy_flask_extension/dummy.py b/example/dummy_flask_extension/dummy.py index 3dc416a33..d46908139 100644 --- a/example/dummy_flask_extension/dummy.py +++ b/example/dummy_flask_extension/dummy.py @@ -1,3 +1,6 @@ +from __future__ import annotations + + def init_app(app): """This extension is only for testing.""" app.is_dummy_loaded = True diff --git a/example/dunder/app.py b/example/dunder/app.py index c8a5ef21b..b3c0ea436 100644 --- a/example/dunder/app.py +++ b/example/dunder/app.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from pprint import pprint from dynaconf import settings diff --git a/example/dunder/other_settings.py b/example/dunder/other_settings.py index dab44e4e9..7960377cf 100644 --- a/example/dunder/other_settings.py +++ b/example/dunder/other_settings.py @@ -1,3 +1,5 @@ +from __future__ import annotations + FILES__all = '@merge ["py"]' FILES__last = ["py"] FILES__loaded__TYPES = '@merge {"py": True}' diff --git a/example/dunder/settings.py b/example/dunder/settings.py index 6b3e7fe90..0af54fe7f 100644 --- a/example/dunder/settings.py +++ b/example/dunder/settings.py @@ -1,3 +1,5 @@ +from __future__ import annotations + FILES = { "all": ["default"], "last": ["default"], diff --git a/example/dynaconf_merge/app.py b/example/dynaconf_merge/app.py index 7d5f647ef..697e75bc9 100644 --- a/example/dynaconf_merge/app.py +++ b/example/dynaconf_merge/app.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from dynaconf import settings assert settings.DATABASE == { diff --git a/example/envless_mode/app.py b/example/envless_mode/app.py index 2df08f173..b7e90c353 100644 --- a/example/envless_mode/app.py +++ b/example/envless_mode/app.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import os from dynaconf import LazySettings diff --git a/example/envs/app.py b/example/envs/app.py index 15d500aff..2a15933b3 100644 --- a/example/envs/app.py +++ b/example/envs/app.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from dynaconf import settings diff --git a/example/envvar_prefix/app.py b/example/envvar_prefix/app.py index 5638cea55..eb88dd647 100644 --- a/example/envvar_prefix/app.py +++ b/example/envvar_prefix/app.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from dynaconf import settings print("EXAMPLE_ prefix") diff --git a/example/fastapi_with_ini/app.py b/example/fastapi_with_ini/app.py index 70d0160a2..b537d7cf0 100644 --- a/example/fastapi_with_ini/app.py +++ b/example/fastapi_with_ini/app.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from typing import Optional from fastapi import FastAPI diff --git a/example/flask_with_commentjson/app.py b/example/flask_with_commentjson/app.py index f1f71f596..2b272d12d 100644 --- a/example/flask_with_commentjson/app.py +++ b/example/flask_with_commentjson/app.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from flask import Flask from flask import render_template diff --git a/example/flask_with_dotenv/app.py b/example/flask_with_dotenv/app.py index 4497b14dc..874887a7b 100644 --- a/example/flask_with_dotenv/app.py +++ b/example/flask_with_dotenv/app.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from flask import Flask from flask import render_template diff --git a/example/flask_with_ini/app.py b/example/flask_with_ini/app.py index eb368459e..81487d0c5 100644 --- a/example/flask_with_ini/app.py +++ b/example/flask_with_ini/app.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from flask import Flask from flask import render_template diff --git a/example/flask_with_json/app.py b/example/flask_with_json/app.py index eb368459e..81487d0c5 100644 --- a/example/flask_with_json/app.py +++ b/example/flask_with_json/app.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from flask import Flask from flask import render_template diff --git a/example/flask_with_toml/app.py b/example/flask_with_toml/app.py index eb368459e..81487d0c5 100644 --- a/example/flask_with_toml/app.py +++ b/example/flask_with_toml/app.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from flask import Flask from flask import render_template diff --git a/example/flask_with_yaml/app.py b/example/flask_with_yaml/app.py index eb368459e..81487d0c5 100644 --- a/example/flask_with_yaml/app.py +++ b/example/flask_with_yaml/app.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from flask import Flask from flask import render_template diff --git a/example/format/app.py b/example/format/app.py index 029d05002..1c2c448ae 100644 --- a/example/format/app.py +++ b/example/format/app.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import os from dynaconf import settings diff --git a/example/full_example.py b/example/full_example.py index 55be18616..9340aa91e 100644 --- a/example/full_example.py +++ b/example/full_example.py @@ -3,6 +3,8 @@ # $export DYNACONF_HOSTNAME=host.com # $export DYNACONF_PORT='@int 5000' # or save to REDIS, yaml, json, ini etc... +from __future__ import annotations + import os from dynaconf import settings diff --git a/example/full_test/settings.py b/example/full_test/settings.py index 99d490559..6df5dbd3e 100644 --- a/example/full_test/settings.py +++ b/example/full_test/settings.py @@ -1 +1,3 @@ +from __future__ import annotations + PYVAR = "Come from settings.py" diff --git a/example/full_test/staging_settings.py b/example/full_test/staging_settings.py index 7e4502382..2959b9938 100644 --- a/example/full_test/staging_settings.py +++ b/example/full_test/staging_settings.py @@ -1 +1,3 @@ +from __future__ import annotations + PYVAR = "Come from staging_settings.py" diff --git a/example/full_test/test.py b/example/full_test/test.py index 496702e57..1820c28f3 100644 --- a/example/full_test/test.py +++ b/example/full_test/test.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from dynaconf import settings # test default loader never gets cleaned diff --git a/example/get_fresh/app.py b/example/get_fresh/app.py index 2c50c43be..a12086e72 100644 --- a/example/get_fresh/app.py +++ b/example/get_fresh/app.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from dynaconf import settings from dynaconf.loaders.toml_loader import write diff --git a/example/ignore_unknown_envvars/app.py b/example/ignore_unknown_envvars/app.py index 5d8b10f3e..4b2b2c2e1 100644 --- a/example/ignore_unknown_envvars/app.py +++ b/example/ignore_unknown_envvars/app.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from dynaconf import LazySettings diff --git a/example/includes/app.py b/example/includes/app.py index 4b719b34e..3578580ae 100644 --- a/example/includes/app.py +++ b/example/includes/app.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from dynaconf import settings assert settings.DYNACONF_INCLUDE == [ diff --git a/example/includes/configs/plugin4.py b/example/includes/configs/plugin4.py index c477a9bf7..24a3c7c25 100644 --- a/example/includes/configs/plugin4.py +++ b/example/includes/configs/plugin4.py @@ -1,3 +1,5 @@ +from __future__ import annotations + PLUGIN4_VAR = True LASTFILE = "configs/plugin4.py" MERGEABLE = {"plugin4": True} diff --git a/example/issues/166_renamed_global_env/app.py b/example/issues/166_renamed_global_env/app.py index 2e70fe1b3..197384be6 100644 --- a/example/issues/166_renamed_global_env/app.py +++ b/example/issues/166_renamed_global_env/app.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from dynaconf import settings assert settings.ENVVAR_PREFIX_FOR_DYNACONF == "GREATAPP" diff --git a/example/issues/169_renamed_settings_module/app.py b/example/issues/169_renamed_settings_module/app.py index b7253e2aa..aa34bdda7 100644 --- a/example/issues/169_renamed_settings_module/app.py +++ b/example/issues/169_renamed_settings_module/app.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from dynaconf import settings assert settings.ENVVAR_PREFIX_FOR_DYNACONF == "GREATAPP" diff --git a/example/issues/182_multiple_locations/app.py b/example/issues/182_multiple_locations/app.py index 4b04aa75a..905c8def2 100644 --- a/example/issues/182_multiple_locations/app.py +++ b/example/issues/182_multiple_locations/app.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import os from dynaconf import settings diff --git a/example/issues/184_ipython/app.py b/example/issues/184_ipython/app.py index 61a3c063d..2e28ab549 100644 --- a/example/issues/184_ipython/app.py +++ b/example/issues/184_ipython/app.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from dynaconf import settings print(settings.ENV_FOR_DYNACONF) diff --git a/example/issues/184_ipython/subdir/app.py b/example/issues/184_ipython/subdir/app.py index 61a3c063d..2e28ab549 100644 --- a/example/issues/184_ipython/subdir/app.py +++ b/example/issues/184_ipython/subdir/app.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from dynaconf import settings print(settings.ENV_FOR_DYNACONF) diff --git a/example/issues/194_flask_config/app.py b/example/issues/194_flask_config/app.py index 7510af49c..44a612713 100644 --- a/example/issues/194_flask_config/app.py +++ b/example/issues/194_flask_config/app.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from flask import Flask from dynaconf import FlaskDynaconf diff --git a/example/issues/228_nested_toml_bool/django_app/django_app/settings.py b/example/issues/228_nested_toml_bool/django_app/django_app/settings.py index c7c26255a..29459df2c 100644 --- a/example/issues/228_nested_toml_bool/django_app/django_app/settings.py +++ b/example/issues/228_nested_toml_bool/django_app/django_app/settings.py @@ -9,6 +9,8 @@ For the full list of settings and their values, see https://docs.djangoproject.com/en/2.2/ref/settings/ """ +from __future__ import annotations + import os import sys diff --git a/example/issues/228_nested_toml_bool/django_app/django_app/urls.py b/example/issues/228_nested_toml_bool/django_app/django_app/urls.py index fe62bbd67..f30c4c7c1 100644 --- a/example/issues/228_nested_toml_bool/django_app/django_app/urls.py +++ b/example/issues/228_nested_toml_bool/django_app/django_app/urls.py @@ -13,6 +13,8 @@ 1. Import the include() function: from django.urls import include, path 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) """ +from __future__ import annotations + from django.contrib import admin from django.urls import path diff --git a/example/issues/228_nested_toml_bool/django_app/django_app/wsgi.py b/example/issues/228_nested_toml_bool/django_app/django_app/wsgi.py index fc5376ece..b957d3e73 100644 --- a/example/issues/228_nested_toml_bool/django_app/django_app/wsgi.py +++ b/example/issues/228_nested_toml_bool/django_app/django_app/wsgi.py @@ -6,6 +6,8 @@ For more information on this file, see https://docs.djangoproject.com/en/2.2/howto/deployment/wsgi/ """ +from __future__ import annotations + import os from django.core.wsgi import get_wsgi_application diff --git a/example/issues/228_nested_toml_bool/django_app/manage.py b/example/issues/228_nested_toml_bool/django_app/manage.py index e3c9b8832..903744cc6 100755 --- a/example/issues/228_nested_toml_bool/django_app/manage.py +++ b/example/issues/228_nested_toml_bool/django_app/manage.py @@ -1,5 +1,7 @@ #!/usr/bin/env python """Django's command-line utility for administrative tasks.""" +from __future__ import annotations + import os import sys diff --git a/example/issues/228_nested_toml_bool/python_app/app.py b/example/issues/228_nested_toml_bool/python_app/app.py index 866861e97..78d89c55b 100644 --- a/example/issues/228_nested_toml_bool/python_app/app.py +++ b/example/issues/228_nested_toml_bool/python_app/app.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from dynaconf import settings print(settings.DEBUG.enabled) diff --git a/example/issues/251_dotted_unexistent/app.py b/example/issues/251_dotted_unexistent/app.py index 54dec440d..08d59def1 100644 --- a/example/issues/251_dotted_unexistent/app.py +++ b/example/issues/251_dotted_unexistent/app.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from dynaconf import settings print("As dict:") diff --git a/example/issues/251_dotted_unexistent/settings.py b/example/issues/251_dotted_unexistent/settings.py index 80f7f324a..90d676c83 100644 --- a/example/issues/251_dotted_unexistent/settings.py +++ b/example/issues/251_dotted_unexistent/settings.py @@ -1 +1,3 @@ +from __future__ import annotations + FOO = {"bar": "hello"} diff --git a/example/issues/253_set/app.py b/example/issues/253_set/app.py index d143e642e..32268aeda 100644 --- a/example/issues/253_set/app.py +++ b/example/issues/253_set/app.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import os from dynaconf import Dynaconf diff --git a/example/issues/266_envvar_from_env_override/app.py b/example/issues/266_envvar_from_env_override/app.py index a47a6205c..bc20cc925 100644 --- a/example/issues/266_envvar_from_env_override/app.py +++ b/example/issues/266_envvar_from_env_override/app.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from dynaconf import settings print(f"Current env: {settings.current_env}") diff --git a/example/issues/284_local_sets/app.py b/example/issues/284_local_sets/app.py index 8c3856fc0..39f99cde5 100644 --- a/example/issues/284_local_sets/app.py +++ b/example/issues/284_local_sets/app.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from dynaconf import Dynaconf settings = Dynaconf( diff --git a/example/issues/288_null_values/app.py b/example/issues/288_null_values/app.py index 016ef0727..56b9717bb 100644 --- a/example/issues/288_null_values/app.py +++ b/example/issues/288_null_values/app.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from dynaconf import settings assert settings["NULLED_VALUE_PYTHON"] is None diff --git a/example/issues/288_null_values/settings.py b/example/issues/288_null_values/settings.py index c82da4208..061686d54 100644 --- a/example/issues/288_null_values/settings.py +++ b/example/issues/288_null_values/settings.py @@ -1 +1,3 @@ +from __future__ import annotations + NULLED_VALUE_PYTHON = None diff --git a/example/issues/306_merge_replace/app.py b/example/issues/306_merge_replace/app.py index 4253aea92..cf6f1900b 100644 --- a/example/issues/306_merge_replace/app.py +++ b/example/issues/306_merge_replace/app.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from dynaconf import settings diff --git a/example/issues/306_merge_replace/development_settings.py b/example/issues/306_merge_replace/development_settings.py index e0631d811..901cd4c75 100644 --- a/example/issues/306_merge_replace/development_settings.py +++ b/example/issues/306_merge_replace/development_settings.py @@ -1,2 +1,4 @@ +from __future__ import annotations + REST_FRAMEWORK__ANOTHER_THING = ["z"] REST_FRAMEWORK__ANOTHER_THING_MERGED = '@merge ["z"]' diff --git a/example/issues/306_merge_replace/settings.py b/example/issues/306_merge_replace/settings.py index e56c81800..a086b80a9 100644 --- a/example/issues/306_merge_replace/settings.py +++ b/example/issues/306_merge_replace/settings.py @@ -1,4 +1,5 @@ # Covering this issue: https://pulp.plan.io/issues/6244 +from __future__ import annotations REST_FRAMEWORK = { "URL_FIELD_NAME": "pulp_href", diff --git a/example/issues/323_DEFAULT_VALUES_RESOLUTION/app.py b/example/issues/323_DEFAULT_VALUES_RESOLUTION/app.py index 903634170..52a2bd8de 100644 --- a/example/issues/323_DEFAULT_VALUES_RESOLUTION/app.py +++ b/example/issues/323_DEFAULT_VALUES_RESOLUTION/app.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from dynaconf import Dynaconf settings = Dynaconf(settings_file="settings.toml", environments=True) diff --git a/example/issues/325_flask_dot_env/app.py b/example/issues/325_flask_dot_env/app.py index 536075b59..970b3b3d6 100644 --- a/example/issues/325_flask_dot_env/app.py +++ b/example/issues/325_flask_dot_env/app.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from flask import Flask app = Flask(__name__) diff --git a/example/issues/327_flask_extensions_warning/app.py b/example/issues/327_flask_extensions_warning/app.py index d2e4e7271..5675113a0 100644 --- a/example/issues/327_flask_extensions_warning/app.py +++ b/example/issues/327_flask_extensions_warning/app.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from flask import Flask from dynaconf import FlaskDynaconf diff --git a/example/issues/341_box_it_up/app.py b/example/issues/341_box_it_up/app.py index 2dd9d2d46..1c9cc674f 100644 --- a/example/issues/341_box_it_up/app.py +++ b/example/issues/341_box_it_up/app.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from dynaconf import Dynaconf settings = Dynaconf(settings_file="settings.yaml") diff --git a/example/issues/359_variable_reference/app.py b/example/issues/359_variable_reference/app.py index 92e2bc5a6..933412b49 100644 --- a/example/issues/359_variable_reference/app.py +++ b/example/issues/359_variable_reference/app.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from dynaconf import Dynaconf settings = Dynaconf(settings_files="settings.yaml", environments=True) diff --git a/example/issues/377_default_validators/app.py b/example/issues/377_default_validators/app.py index 2c496fe38..fa3f2ef87 100644 --- a/example/issues/377_default_validators/app.py +++ b/example/issues/377_default_validators/app.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from dynaconf import Dynaconf from dynaconf import Validator diff --git a/example/issues/379_dict_like_iteration/app.py b/example/issues/379_dict_like_iteration/app.py index 3800c6551..77981990b 100644 --- a/example/issues/379_dict_like_iteration/app.py +++ b/example/issues/379_dict_like_iteration/app.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from dynaconf import Dynaconf settings = Dynaconf( diff --git a/example/issues/384_dotted_set/app.py b/example/issues/384_dotted_set/app.py index aef17ffbd..95224c91a 100644 --- a/example/issues/384_dotted_set/app.py +++ b/example/issues/384_dotted_set/app.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from dynaconf import Dynaconf settings = Dynaconf() diff --git a/example/issues/392_evaluate_nested_structures/app.py b/example/issues/392_evaluate_nested_structures/app.py index db83e7bd7..a7cbe7854 100644 --- a/example/issues/392_evaluate_nested_structures/app.py +++ b/example/issues/392_evaluate_nested_structures/app.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from dynaconf import Dynaconf settings = Dynaconf( diff --git a/example/issues/404_dup_validator_message/app.py b/example/issues/404_dup_validator_message/app.py index 6dc900cb5..1c6242505 100644 --- a/example/issues/404_dup_validator_message/app.py +++ b/example/issues/404_dup_validator_message/app.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from dynaconf import Dynaconf from dynaconf import ValidationError from dynaconf import Validator diff --git a/example/issues/430_same_name/app.py b/example/issues/430_same_name/app.py index 9c27a6e7c..bc068465c 100644 --- a/example/issues/430_same_name/app.py +++ b/example/issues/430_same_name/app.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from dynaconf import Dynaconf settings = Dynaconf( diff --git a/example/issues/434_setenv/app.py b/example/issues/434_setenv/app.py index 967f0a7f7..a62d4a75d 100644 --- a/example/issues/434_setenv/app.py +++ b/example/issues/434_setenv/app.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import click from dynaconf import Dynaconf diff --git a/example/issues/434_setenv/config.py b/example/issues/434_setenv/config.py index 026d092ba..7ee77d9d0 100644 --- a/example/issues/434_setenv/config.py +++ b/example/issues/434_setenv/config.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from dynaconf import Dynaconf settings = Dynaconf( diff --git a/example/issues/443_object_merge/app.py b/example/issues/443_object_merge/app.py index 91e31b088..a0dfe061e 100644 --- a/example/issues/443_object_merge/app.py +++ b/example/issues/443_object_merge/app.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from dynaconf.utils import object_merge from dynaconf.utils.boxing import DynaBox diff --git a/example/issues/445_casting/app.py b/example/issues/445_casting/app.py index ed5b0382f..6b7825295 100644 --- a/example/issues/445_casting/app.py +++ b/example/issues/445_casting/app.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from dynaconf import Dynaconf settings = Dynaconf(load_dotenv=True) diff --git a/example/issues/449_django_lazy_path/foo/settings.py b/example/issues/449_django_lazy_path/foo/settings.py index abbd3ef52..c6a48bdff 100644 --- a/example/issues/449_django_lazy_path/foo/settings.py +++ b/example/issues/449_django_lazy_path/foo/settings.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import os # Where is all the Django's settings? diff --git a/example/issues/449_django_lazy_path/foo/urls.py b/example/issues/449_django_lazy_path/foo/urls.py index 55e6d68a6..99d185c15 100644 --- a/example/issues/449_django_lazy_path/foo/urls.py +++ b/example/issues/449_django_lazy_path/foo/urls.py @@ -13,6 +13,8 @@ 1. Import the include() function: from django.urls import include, path 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) """ +from __future__ import annotations + from django.conf import settings from django.contrib import admin from django.urls import include diff --git a/example/issues/449_django_lazy_path/foo/wsgi.py b/example/issues/449_django_lazy_path/foo/wsgi.py index 45625459d..f2fc605d0 100644 --- a/example/issues/449_django_lazy_path/foo/wsgi.py +++ b/example/issues/449_django_lazy_path/foo/wsgi.py @@ -6,6 +6,8 @@ For more information on this file, see https://docs.djangoproject.com/en/2.0/howto/deployment/wsgi/ """ +from __future__ import annotations + import os from django.core.wsgi import get_wsgi_application diff --git a/example/issues/449_django_lazy_path/manage.py b/example/issues/449_django_lazy_path/manage.py index db3dbcdf2..9624fc0ae 100755 --- a/example/issues/449_django_lazy_path/manage.py +++ b/example/issues/449_django_lazy_path/manage.py @@ -1,4 +1,6 @@ #!/usr/bin/env python +from __future__ import annotations + import os import sys diff --git a/example/issues/449_django_lazy_path/polls/admin.py b/example/issues/449_django_lazy_path/polls/admin.py index 8c38f3f3d..07d205914 100644 --- a/example/issues/449_django_lazy_path/polls/admin.py +++ b/example/issues/449_django_lazy_path/polls/admin.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from django.contrib import admin # Register your models here. diff --git a/example/issues/449_django_lazy_path/polls/apps.py b/example/issues/449_django_lazy_path/polls/apps.py index 292f00d13..654d697e2 100644 --- a/example/issues/449_django_lazy_path/polls/apps.py +++ b/example/issues/449_django_lazy_path/polls/apps.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from django.apps import AppConfig diff --git a/example/issues/449_django_lazy_path/polls/models.py b/example/issues/449_django_lazy_path/polls/models.py index 71a836239..48c5c6ae5 100644 --- a/example/issues/449_django_lazy_path/polls/models.py +++ b/example/issues/449_django_lazy_path/polls/models.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from django.db import models # Create your models here. diff --git a/example/issues/449_django_lazy_path/polls/tests.py b/example/issues/449_django_lazy_path/polls/tests.py index 4ee0a430c..8e424c736 100644 --- a/example/issues/449_django_lazy_path/polls/tests.py +++ b/example/issues/449_django_lazy_path/polls/tests.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from django.conf import settings from django.test import TestCase diff --git a/example/issues/449_django_lazy_path/polls/urls.py b/example/issues/449_django_lazy_path/polls/urls.py index 7ece5c998..a0994e6cf 100644 --- a/example/issues/449_django_lazy_path/polls/urls.py +++ b/example/issues/449_django_lazy_path/polls/urls.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from django.urls import path from . import views diff --git a/example/issues/449_django_lazy_path/polls/views.py b/example/issues/449_django_lazy_path/polls/views.py index 48b88cdf9..cee1ec262 100644 --- a/example/issues/449_django_lazy_path/polls/views.py +++ b/example/issues/449_django_lazy_path/polls/views.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from django.conf import settings from django.http import HttpResponse diff --git a/example/issues/449_django_lazy_path/pulpsettings.py b/example/issues/449_django_lazy_path/pulpsettings.py index 34052454e..269dd6810 100644 --- a/example/issues/449_django_lazy_path/pulpsettings.py +++ b/example/issues/449_django_lazy_path/pulpsettings.py @@ -1,3 +1,5 @@ +from __future__ import annotations + REST_FRAMEWORK__DEFAULT_AUTHENTICATION_CLASSES = ( "rest_framework.authentication.SessionAuthentication", "pulpcore.app.authentication.PulpRemoteUserAuthentication", diff --git a/example/issues/449_django_lazy_path/standalone_script.py b/example/issues/449_django_lazy_path/standalone_script.py index e8a127f49..941408aed 100644 --- a/example/issues/449_django_lazy_path/standalone_script.py +++ b/example/issues/449_django_lazy_path/standalone_script.py @@ -1,4 +1,6 @@ # You should start your standalone scripts with this: +from __future__ import annotations + from django.conf import settings # This `DYNACONF.configure()` line may be useful in some cases diff --git a/example/issues/467_load_from_parent_folder/src/app.py b/example/issues/467_load_from_parent_folder/src/app.py index 499170565..6b35111a2 100644 --- a/example/issues/467_load_from_parent_folder/src/app.py +++ b/example/issues/467_load_from_parent_folder/src/app.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from dynaconf import Dynaconf diff --git a/example/issues/478_mispell_environments/app.py b/example/issues/478_mispell_environments/app.py index 38b832490..f8fc4f6d0 100644 --- a/example/issues/478_mispell_environments/app.py +++ b/example/issues/478_mispell_environments/app.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from dynaconf import Dynaconf diff --git a/example/issues/482_layered_format/app.py b/example/issues/482_layered_format/app.py index f747462b4..6da4214b9 100644 --- a/example/issues/482_layered_format/app.py +++ b/example/issues/482_layered_format/app.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from dynaconf import Dynaconf settings_files = ["settings.toml", "other.toml"] diff --git a/example/issues/486_title_case_validation/app.py b/example/issues/486_title_case_validation/app.py index cf547eef2..79482bdfc 100644 --- a/example/issues/486_title_case_validation/app.py +++ b/example/issues/486_title_case_validation/app.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from pathlib import Path from dynaconf import Dynaconf diff --git a/example/issues/494_using_pathlib/app.py b/example/issues/494_using_pathlib/app.py index 200d08916..514b886de 100644 --- a/example/issues/494_using_pathlib/app.py +++ b/example/issues/494_using_pathlib/app.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from pathlib import Path from dynaconf import Dynaconf diff --git a/example/issues/519_underscore_in_name/app.py b/example/issues/519_underscore_in_name/app.py index 6de587e5f..5b73907cf 100644 --- a/example/issues/519_underscore_in_name/app.py +++ b/example/issues/519_underscore_in_name/app.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import os from dynaconf import Dynaconf diff --git a/example/issues/685_disable_dotted_lookup/app.py b/example/issues/685_disable_dotted_lookup/app.py index 22b5081bf..bb802b8ab 100644 --- a/example/issues/685_disable_dotted_lookup/app.py +++ b/example/issues/685_disable_dotted_lookup/app.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import yaml from dynaconf import Dynaconf diff --git a/example/issues/709_yaml_merge_with_env/app.py b/example/issues/709_yaml_merge_with_env/app.py index a0cd5b7d0..cf921a038 100644 --- a/example/issues/709_yaml_merge_with_env/app.py +++ b/example/issues/709_yaml_merge_with_env/app.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from dynaconf import Dynaconf settings = Dynaconf( diff --git a/example/issues/718_dynaconf_dotted_lookup/app.py b/example/issues/718_dynaconf_dotted_lookup/app.py index a4985dcf3..6600dcb96 100644 --- a/example/issues/718_dynaconf_dotted_lookup/app.py +++ b/example/issues/718_dynaconf_dotted_lookup/app.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from dynaconf import Dynaconf settings = Dynaconf( diff --git a/example/issues/720_load_dotenv/src/app/app.py b/example/issues/720_load_dotenv/src/app/app.py index 77a1382b7..d7c116fd9 100644 --- a/example/issues/720_load_dotenv/src/app/app.py +++ b/example/issues/720_load_dotenv/src/app/app.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import os from pathlib import Path diff --git a/example/issues/729_use_default_when_setting_is_blank/app.py b/example/issues/729_use_default_when_setting_is_blank/app.py index 3a3c156a9..db58d12d5 100644 --- a/example/issues/729_use_default_when_setting_is_blank/app.py +++ b/example/issues/729_use_default_when_setting_is_blank/app.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from dynaconf import Dynaconf from dynaconf import Validator diff --git a/example/issues/734_validate_only_current_env/app.py b/example/issues/734_validate_only_current_env/app.py index 44fd2c761..9e371d8f1 100644 --- a/example/issues/734_validate_only_current_env/app.py +++ b/example/issues/734_validate_only_current_env/app.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from dynaconf import Dynaconf from dynaconf import ValidationError from dynaconf import Validator diff --git a/example/issues/741_envvars_ignored/app.py b/example/issues/741_envvars_ignored/app.py index a60bdb3af..578fb50fb 100644 --- a/example/issues/741_envvars_ignored/app.py +++ b/example/issues/741_envvars_ignored/app.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from dynaconf import Dynaconf from dynaconf import Validator diff --git a/example/jenkins_secrets_file/app.py b/example/jenkins_secrets_file/app.py index c4f87a29d..4d4c8bbb7 100644 --- a/example/jenkins_secrets_file/app.py +++ b/example/jenkins_secrets_file/app.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from dynaconf import settings # Assuming this app is running on CI the secret values would be read from diff --git a/example/lower_read/app.py b/example/lower_read/app.py index 55ac23fb0..ecad74238 100644 --- a/example/lower_read/app.py +++ b/example/lower_read/app.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from dynaconf import LazySettings settings = LazySettings(settings_files="settings.yaml") diff --git a/example/merge_enabled/app.py b/example/merge_enabled/app.py index 71c8b02a1..0a267e6e9 100644 --- a/example/merge_enabled/app.py +++ b/example/merge_enabled/app.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from dynaconf import settings print("Read from settings.py:", settings.PYTHON_VAR) # noqa diff --git a/example/merge_enabled/development_settings.py b/example/merge_enabled/development_settings.py index 165319d54..1c6bc089a 100644 --- a/example/merge_enabled/development_settings.py +++ b/example/merge_enabled/development_settings.py @@ -1,2 +1,4 @@ +from __future__ import annotations + PYTHON_DEV_VAR = 1 A_BIG_DICT = {"file": {"development_settings.py": True}} diff --git a/example/merge_enabled/global_settings.py b/example/merge_enabled/global_settings.py index 7ae2826de..a462e6435 100644 --- a/example/merge_enabled/global_settings.py +++ b/example/merge_enabled/global_settings.py @@ -1,2 +1,4 @@ +from __future__ import annotations + PYTHON_GLOBAL_VAR = 1 A_BIG_DICT = {"file": {"global_settings.py": True}} diff --git a/example/merge_enabled/production_settings.py b/example/merge_enabled/production_settings.py index 679330236..beafc3c4e 100644 --- a/example/merge_enabled/production_settings.py +++ b/example/merge_enabled/production_settings.py @@ -1 +1,3 @@ +from __future__ import annotations + PYTHON_PROD_VAR = 1 diff --git a/example/merge_enabled/settings.py b/example/merge_enabled/settings.py index 62b33e68f..9f8705f45 100644 --- a/example/merge_enabled/settings.py +++ b/example/merge_enabled/settings.py @@ -1,3 +1,5 @@ +from __future__ import annotations + PYTHON_VAR = 1 A_BIG_DICT = { "file": {"settings.py": True}, diff --git a/example/module_impersonation/main.py b/example/module_impersonation/main.py index 363fae932..c2a30b48a 100644 --- a/example/module_impersonation/main.py +++ b/example/module_impersonation/main.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import settings print(settings.USER) diff --git a/example/module_impersonation/settings.py b/example/module_impersonation/settings.py index afcc4662a..2a0d218c8 100644 --- a/example/module_impersonation/settings.py +++ b/example/module_impersonation/settings.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import sys from dynaconf import Dynaconf diff --git a/example/multiple_folders/app.py b/example/multiple_folders/app.py index d79a70752..e3290e701 100644 --- a/example/multiple_folders/app.py +++ b/example/multiple_folders/app.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from dynaconf import settings print("development") diff --git a/example/multiple_sources/app.py b/example/multiple_sources/app.py index eb928e02e..50888d6da 100644 --- a/example/multiple_sources/app.py +++ b/example/multiple_sources/app.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from dynaconf import settings print("Read from settings.py:", settings.PYTHON_VAR) # noqa diff --git a/example/multiple_sources/development_settings.py b/example/multiple_sources/development_settings.py index 3bddb8b30..ad36b3736 100644 --- a/example/multiple_sources/development_settings.py +++ b/example/multiple_sources/development_settings.py @@ -1 +1,3 @@ +from __future__ import annotations + PYTHON_DEV_VAR = 1 diff --git a/example/multiple_sources/global_settings.py b/example/multiple_sources/global_settings.py index c60323bf9..83d6b27a5 100644 --- a/example/multiple_sources/global_settings.py +++ b/example/multiple_sources/global_settings.py @@ -1 +1,3 @@ +from __future__ import annotations + PYTHON_GLOBAL_VAR = 1 diff --git a/example/multiple_sources/production_settings.py b/example/multiple_sources/production_settings.py index 679330236..beafc3c4e 100644 --- a/example/multiple_sources/production_settings.py +++ b/example/multiple_sources/production_settings.py @@ -1 +1,3 @@ +from __future__ import annotations + PYTHON_PROD_VAR = 1 diff --git a/example/multiple_sources/settings.py b/example/multiple_sources/settings.py index e47ea2d19..a09b5d4bf 100644 --- a/example/multiple_sources/settings.py +++ b/example/multiple_sources/settings.py @@ -1 +1,3 @@ +from __future__ import annotations + PYTHON_VAR = 1 diff --git a/example/new_merge/app.py b/example/new_merge/app.py index 193979bc3..6ef04b988 100644 --- a/example/new_merge/app.py +++ b/example/new_merge/app.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from dynaconf import settings assert settings.PY_MERGE_LIST == [1, 2], settings.PY_MERGE_LIST diff --git a/example/new_merge/settings.local.py b/example/new_merge/settings.local.py index 0eddf591b..56646435a 100644 --- a/example/new_merge/settings.local.py +++ b/example/new_merge/settings.local.py @@ -1,3 +1,5 @@ +from __future__ import annotations + DYNACONF_MERGE = True FILES = ["settings.local.py"] PERSON = {"country": "Brasil"} diff --git a/example/new_merge/settings.py b/example/new_merge/settings.py index 29e327f07..a10af73c1 100644 --- a/example/new_merge/settings.py +++ b/example/new_merge/settings.py @@ -1,3 +1,5 @@ +from __future__ import annotations + FILES = ["settings.py"] PERSON = {"name": "Bruno"} PY_MERGE_LIST = [1] diff --git a/example/overriding/app.py b/example/overriding/app.py index a6638a7f4..05bda2804 100644 --- a/example/overriding/app.py +++ b/example/overriding/app.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from dynaconf import settings diff --git a/example/overriding/settings.py b/example/overriding/settings.py index edc2cc79a..719b022b8 100644 --- a/example/overriding/settings.py +++ b/example/overriding/settings.py @@ -1,3 +1,5 @@ +from __future__ import annotations + REST_FRAMEWORK = { "URL_FIELD_NAME": "pulp_href", "DEFAULT_FILTER_BACKENDS": ( diff --git a/example/overriding/user_settings.py b/example/overriding/user_settings.py index 96a507e6e..b77751ded 100644 --- a/example/overriding/user_settings.py +++ b/example/overriding/user_settings.py @@ -1,6 +1,7 @@ # Alternative 1 # This works # https://www.dynaconf.com/merging/#merging-existing-data-structures +from __future__ import annotations REST_FRAMEWORK__DEFAULT_AUTHENTICATION_CLASSES = [ "rest_framework.authentication.SessionAuthentication", diff --git a/example/project_root/app.py b/example/project_root/app.py index 4a0e194d3..62bcbb940 100644 --- a/example/project_root/app.py +++ b/example/project_root/app.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from dynaconf import settings assert settings.MESSAGE == "Hello from tmp" diff --git a/example/pytest_example/app/app.py b/example/pytest_example/app/app.py index e3471b841..3b5ac03d1 100644 --- a/example/pytest_example/app/app.py +++ b/example/pytest_example/app/app.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from dynaconf import settings diff --git a/example/pytest_example/app/tests/conftest.py b/example/pytest_example/app/tests/conftest.py index dc327a467..8099432d5 100644 --- a/example/pytest_example/app/tests/conftest.py +++ b/example/pytest_example/app/tests/conftest.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import pytest from dynaconf import settings diff --git a/example/pytest_example/app/tests/test_dynaconf.py b/example/pytest_example/app/tests/test_dynaconf.py index f1dba597b..1e55d7324 100644 --- a/example/pytest_example/app/tests/test_dynaconf.py +++ b/example/pytest_example/app/tests/test_dynaconf.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from app import return_a_value diff --git a/example/pytest_example/flask/src.py b/example/pytest_example/flask/src.py index 431a7e3b3..cf100079d 100644 --- a/example/pytest_example/flask/src.py +++ b/example/pytest_example/flask/src.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from flask import Flask from dynaconf.contrib import FlaskDynaconf diff --git a/example/pytest_example/flask/tests/conftest.py b/example/pytest_example/flask/tests/conftest.py index 566c41afd..2ca256053 100644 --- a/example/pytest_example/flask/tests/conftest.py +++ b/example/pytest_example/flask/tests/conftest.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import pytest from src import create_app diff --git a/example/pytest_example/flask/tests/test_flask_dynaconf.py b/example/pytest_example/flask/tests/test_flask_dynaconf.py index 04c77a6d8..af63b1da2 100644 --- a/example/pytest_example/flask/tests/test_flask_dynaconf.py +++ b/example/pytest_example/flask/tests/test_flask_dynaconf.py @@ -1,3 +1,6 @@ +from __future__ import annotations + + def test_dynaconf_is_on_testing_env(app): assert app.config["VALUE"] == "On Testing" assert app.config.current_env == "testing" diff --git a/example/python_loader/app.py b/example/python_loader/app.py index 837ddd54f..58bb40f2c 100644 --- a/example/python_loader/app.py +++ b/example/python_loader/app.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from dynaconf import Dynaconf settings = Dynaconf(settings_file="setting.py", SILENT_ERRORS=False) diff --git a/example/python_loader/setting.py b/example/python_loader/setting.py index fae9a51b7..508dc69ac 100644 --- a/example/python_loader/setting.py +++ b/example/python_loader/setting.py @@ -1 +1,3 @@ +from __future__ import annotations + FOO = "BAR" diff --git a/example/python_loader_with_hooks/app.py b/example/python_loader_with_hooks/app.py index da3680118..d10c3d679 100644 --- a/example/python_loader_with_hooks/app.py +++ b/example/python_loader_with_hooks/app.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from dynaconf import Dynaconf settings = Dynaconf(settings_file="setting.py") diff --git a/example/python_loader_with_hooks/dynaconf_hooks.py b/example/python_loader_with_hooks/dynaconf_hooks.py index 742d6ebff..adcb77527 100644 --- a/example/python_loader_with_hooks/dynaconf_hooks.py +++ b/example/python_loader_with_hooks/dynaconf_hooks.py @@ -1,2 +1,5 @@ +from __future__ import annotations + + def post(settings): return {"BAR": "zaz"} diff --git a/example/python_loader_with_hooks/setting.py b/example/python_loader_with_hooks/setting.py index fae9a51b7..508dc69ac 100644 --- a/example/python_loader_with_hooks/setting.py +++ b/example/python_loader_with_hooks/setting.py @@ -1 +1,3 @@ +from __future__ import annotations + FOO = "BAR" diff --git a/example/redis_example/redis_example.py b/example/redis_example/redis_example.py index 5f2980966..642f4a68f 100644 --- a/example/redis_example/redis_example.py +++ b/example/redis_example/redis_example.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from dynaconf import settings print(settings.FOO) # noqa diff --git a/example/redis_example/write.py b/example/redis_example/write.py index b238a86c2..9ef30730c 100644 --- a/example/redis_example/write.py +++ b/example/redis_example/write.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from dynaconf import settings from dynaconf.loaders import redis_loader diff --git a/example/settings_file/app.py b/example/settings_file/app.py index 4a0e194d3..62bcbb940 100644 --- a/example/settings_file/app.py +++ b/example/settings_file/app.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from dynaconf import settings assert settings.MESSAGE == "Hello from tmp" diff --git a/example/simple/app.py b/example/simple/app.py index f4ef09ce7..3a6895089 100644 --- a/example/simple/app.py +++ b/example/simple/app.py @@ -1,3 +1,5 @@ +from __future__ import annotations + print("# Starting", __file__) print("# On import level dynaconf will read .env and config envvars") print("# It will also setup the initial search tree.") diff --git a/example/simple/settings.py b/example/simple/settings.py index 6b7587146..0f18b8381 100644 --- a/example/simple/settings.py +++ b/example/simple/settings.py @@ -1 +1,3 @@ +from __future__ import annotations + HELLO = "WORLD" diff --git a/example/simple_ini_example/app.py b/example/simple_ini_example/app.py index 8d7c0153b..788fa29eb 100644 --- a/example/simple_ini_example/app.py +++ b/example/simple_ini_example/app.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from dynaconf import Dynaconf diff --git a/example/specific_settings_files/app.py b/example/specific_settings_files/app.py index 9d659af02..f4d7db64f 100644 --- a/example/specific_settings_files/app.py +++ b/example/specific_settings_files/app.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from dynaconf import settings assert settings.FIRST_VAR == "first_value" diff --git a/example/specific_settings_files/extra_settings.py b/example/specific_settings_files/extra_settings.py index e7d77a203..d659a1c01 100644 --- a/example/specific_settings_files/extra_settings.py +++ b/example/specific_settings_files/extra_settings.py @@ -1 +1,3 @@ +from __future__ import annotations + EXTRA_VAR = "extra_value" diff --git a/example/toml_example/app.py b/example/toml_example/app.py index fa9b21843..13d102698 100644 --- a/example/toml_example/app.py +++ b/example/toml_example/app.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from dynaconf import Dynaconf from dynaconf import settings from dynaconf.strategies.filtering import PrefixFilter diff --git a/example/toml_with_secrets/program.py b/example/toml_with_secrets/program.py index bee529e18..bc236e9a5 100644 --- a/example/toml_with_secrets/program.py +++ b/example/toml_with_secrets/program.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from dynaconf import LazySettings settings = LazySettings( diff --git a/example/validators/with_python/app.py b/example/validators/with_python/app.py index b717f7191..8d07e70a5 100644 --- a/example/validators/with_python/app.py +++ b/example/validators/with_python/app.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from conf import settings print(settings.MYSQL_HOST) # noqa diff --git a/example/validators/with_python/conf.py b/example/validators/with_python/conf.py index e8f773a48..71e4c6e07 100644 --- a/example/validators/with_python/conf.py +++ b/example/validators/with_python/conf.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from dynaconf import LazySettings from dynaconf import Validator from dynaconf.utils.parse_conf import Lazy diff --git a/example/validators/with_python/development_settings.py b/example/validators/with_python/development_settings.py index 642680eb1..51f1fcd6e 100644 --- a/example/validators/with_python/development_settings.py +++ b/example/validators/with_python/development_settings.py @@ -1,3 +1,5 @@ +from __future__ import annotations + EXAMPLE = True MYSQL_HOST = "development.com" VERSION = 1 diff --git a/example/validators/with_python/production_settings.py b/example/validators/with_python/production_settings.py index e1e78d387..13c1c2d75 100644 --- a/example/validators/with_python/production_settings.py +++ b/example/validators/with_python/production_settings.py @@ -1,3 +1,5 @@ +from __future__ import annotations + EXAMPLE = True MYSQL_HOST = "production.com" VERSION = 1 diff --git a/example/validators/with_python/settings.py b/example/validators/with_python/settings.py index 0e6814b97..fec3ddbce 100644 --- a/example/validators/with_python/settings.py +++ b/example/validators/with_python/settings.py @@ -1,3 +1,5 @@ +from __future__ import annotations + EXAMPLE = True MYSQL_HOST = "localhost" DEV_SERVERS = ("127.0.0.1", "localhost", "development.com") diff --git a/example/validators/with_toml/config.py b/example/validators/with_toml/config.py index 169dd1726..8de6bad78 100644 --- a/example/validators/with_toml/config.py +++ b/example/validators/with_toml/config.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from dynaconf import Dynaconf settings = Dynaconf(environments=True, settings_file="settings.toml") diff --git a/example/vault/vault_example.py b/example/vault/vault_example.py index 4fea5c2d5..dae1681ac 100644 --- a/example/vault/vault_example.py +++ b/example/vault/vault_example.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from dynaconf import settings from dynaconf.loaders.vault_loader import list_envs @@ -11,7 +13,7 @@ assert settings.SECRET == "vault_works_in_default" available_envs = list_envs(settings, "dynaconf/") -assert set(available_envs) == set(["default", "dev", "prod"]), available_envs +assert set(available_envs) == {"default", "dev", "prod"}, available_envs all_secrets = [] diff --git a/example/vault/write.py b/example/vault/write.py index a3ba84ec1..db4945d50 100644 --- a/example/vault/write.py +++ b/example/vault/write.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from dynaconf import settings from dynaconf.loaders import vault_loader diff --git a/example/yaml_example/settings_file/app.py b/example/yaml_example/settings_file/app.py index 2d74047f0..b4f8f67ca 100644 --- a/example/yaml_example/settings_file/app.py +++ b/example/yaml_example/settings_file/app.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from dynaconf import LazySettings from dynaconf import settings from dynaconf.strategies.filtering import PrefixFilter diff --git a/example/yaml_example/yaml_as_extra_config/app.py b/example/yaml_example/yaml_as_extra_config/app.py index 0b1efad26..02bedcf4a 100644 --- a/example/yaml_example/yaml_as_extra_config/app.py +++ b/example/yaml_example/yaml_as_extra_config/app.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from dynaconf import settings print(settings.YAML) diff --git a/example/yaml_example/yaml_as_extra_config/settings.py b/example/yaml_example/yaml_as_extra_config/settings.py index 6b1ec7516..cc74ce62b 100644 --- a/example/yaml_example/yaml_as_extra_config/settings.py +++ b/example/yaml_example/yaml_as_extra_config/settings.py @@ -1,3 +1,5 @@ +from __future__ import annotations + HOST = "default.com" PORT = 9000 YAML = "extra_settings.yaml" # DEPRECATED diff --git a/setup.py b/setup.py index 05147bc01..82d47fb0c 100644 --- a/setup.py +++ b/setup.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import io import os import sys @@ -9,7 +11,7 @@ def read(*names, **kwargs): """Read a file.""" content = "" - with io.open( + with open( os.path.join(os.path.dirname(__file__), *names), encoding=kwargs.get("encoding", "utf8"), ) as open_file: diff --git a/tests/config.py b/tests/config.py index 3c4b95045..fa61a1c73 100644 --- a/tests/config.py +++ b/tests/config.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from dynaconf import Dynaconf settingsenv = Dynaconf(environments=True) diff --git a/tests/conftest.py b/tests/conftest.py index 7074509bc..cb1a87245 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import copy import os import sys diff --git a/tests/test_base.py b/tests/test_base.py index 062ed433e..66249e61e 100644 --- a/tests/test_base.py +++ b/tests/test_base.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import os import pytest diff --git a/tests/test_basic.py b/tests/test_basic.py index feedc77ac..c102c8f7c 100644 --- a/tests/test_basic.py +++ b/tests/test_basic.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from dynaconf import settings diff --git a/tests/test_cli.py b/tests/test_cli.py index d4c837e03..ed6c948d1 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import json import os from pathlib import Path diff --git a/tests/test_compat.py b/tests/test_compat.py index 55fcd4cd5..52055801f 100644 --- a/tests/test_compat.py +++ b/tests/test_compat.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import os import pytest diff --git a/tests/test_django.py b/tests/test_django.py index 92e3bd0a5..9e8c281b1 100644 --- a/tests/test_django.py +++ b/tests/test_django.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import os import sys diff --git a/tests/test_dynabox.py b/tests/test_dynabox.py index 6b7130348..f68835f3e 100644 --- a/tests/test_dynabox.py +++ b/tests/test_dynabox.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from collections import namedtuple import pytest diff --git a/tests/test_endtoend.py b/tests/test_endtoend.py index 98ec819a1..725b02037 100644 --- a/tests/test_endtoend.py +++ b/tests/test_endtoend.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import os diff --git a/tests/test_env_loader.py b/tests/test_env_loader.py index 3dc98b9fe..2d99ea41d 100644 --- a/tests/test_env_loader.py +++ b/tests/test_env_loader.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import os import sys from collections import OrderedDict @@ -71,7 +73,7 @@ def test_write(tmpdir): ground_truth = SETTINGS_DATA_GROUND_TRUTH.split("\n") - with open(str(settings_path), "r") as fp: + with open(str(settings_path)) as fp: lines = fp.readlines() for idx, line in enumerate(lines): line = line.strip() diff --git a/tests/test_envvar_prefix.py b/tests/test_envvar_prefix.py index 47bc76eb1..35011b48f 100644 --- a/tests/test_envvar_prefix.py +++ b/tests/test_envvar_prefix.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import os import pytest diff --git a/tests/test_feature_flag.py b/tests/test_feature_flag.py index 8e900c8a1..5cbdeb580 100644 --- a/tests/test_feature_flag.py +++ b/tests/test_feature_flag.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import os from dynaconf import LazySettings diff --git a/tests/test_flask.py b/tests/test_flask.py index 15e5a926a..ecafd4a65 100644 --- a/tests/test_flask.py +++ b/tests/test_flask.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from collections import namedtuple import pytest diff --git a/tests/test_ini_loader.py b/tests/test_ini_loader.py index d6e3183c9..9beda0641 100644 --- a/tests/test_ini_loader.py +++ b/tests/test_ini_loader.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import pytest from dynaconf import LazySettings diff --git a/tests/test_json_loader.py b/tests/test_json_loader.py index 0aa6a4942..53f0f6d90 100644 --- a/tests/test_json_loader.py +++ b/tests/test_json_loader.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import json import pytest diff --git a/tests/test_nested_loading.py b/tests/test_nested_loading.py index 0466407a1..543b3dcbe 100644 --- a/tests/test_nested_loading.py +++ b/tests/test_nested_loading.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import pytest from dynaconf.base import LazySettings diff --git a/tests/test_py_loader.py b/tests/test_py_loader.py index e9000c6eb..625d87c8a 100644 --- a/tests/test_py_loader.py +++ b/tests/test_py_loader.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import io import os @@ -14,7 +16,7 @@ def test_py_loader_from_file(tmpdir): settings = DynaconfDict() dummy_path = tmpdir.join("dummy_module.py") - with io.open( + with open( str(dummy_path), "w", encoding=default_settings.ENCODING_FOR_DYNACONF ) as f: f.write('FOO = "bar"') @@ -78,7 +80,7 @@ def test_py_loader_from_file_dunder(clean_env, tmpdir): } ) dummy_path = tmpdir.join("dummy_module.py") - with io.open( + with open( str(dummy_path), "w", encoding=default_settings.ENCODING_FOR_DYNACONF ) as f: f.write('F = "bar"') @@ -149,7 +151,7 @@ def test_post_load_hooks(clean_env, tmpdir): } for path, lines in to_write.items(): - with io.open( + with open( str(path), "w", encoding=default_settings.ENCODING_FOR_DYNACONF ) as f: for line in lines: diff --git a/tests/test_redis.py b/tests/test_redis.py index 5857958ce..3c6b02bd4 100644 --- a/tests/test_redis.py +++ b/tests/test_redis.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import os import pytest diff --git a/tests/test_toml_loader.py b/tests/test_toml_loader.py index fa6a7ddd5..9a5276c95 100644 --- a/tests/test_toml_loader.py +++ b/tests/test_toml_loader.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import pytest from dynaconf import LazySettings diff --git a/tests/test_utils.py b/tests/test_utils.py index 5d84fff05..d2cf15821 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import io import json import os @@ -92,7 +94,7 @@ def test_find_file(tmpdir): # now place a .env file a few levels up and make sure it's found filename = os.path.join(str(child4), ".env") - with io.open( + with open( filename, "w", encoding=default_settings.ENCODING_FOR_DYNACONF ) as f: f.write("TEST=test\n") diff --git a/tests/test_validators.py b/tests/test_validators.py index d57dc644b..bf67a92e9 100644 --- a/tests/test_validators.py +++ b/tests/test_validators.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import os from types import MappingProxyType diff --git a/tests/test_validators_conditions.py b/tests/test_validators_conditions.py index 9b8bf681f..18d1d7ee7 100644 --- a/tests/test_validators_conditions.py +++ b/tests/test_validators_conditions.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import pytest from dynaconf import validator_conditions diff --git a/tests/test_vault.py b/tests/test_vault.py index ea6e20ae4..ad9698ce4 100644 --- a/tests/test_vault.py +++ b/tests/test_vault.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import os from time import sleep diff --git a/tests/test_yaml_loader.py b/tests/test_yaml_loader.py index 9e98d1540..62ccd0529 100644 --- a/tests/test_yaml_loader.py +++ b/tests/test_yaml_loader.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import os import pytest @@ -229,7 +231,7 @@ def test_local_files(tmpdir): conf = LazySettings(environments=True, settings_file="settings.yaml") assert conf.NAME == "Bruno Rocha" - assert set(conf.COLORS) == set(["red", "green", "blue"]) + assert set(conf.COLORS) == {"red", "green", "blue"} assert conf.DATA.link == "brunorocha.org" assert conf.DATA.city == "Guarulhos" assert conf.OTHER == {"baz": "zaz"} @@ -279,7 +281,7 @@ def test_explicit_local_files(tmpdir): ) assert conf.NAME == "Bruno Rocha" - assert set(conf.COLORS) == set(["red", "green", "blue"]) + assert set(conf.COLORS) == {"red", "green", "blue"} assert conf.DATA.link == "brunorocha.org" assert conf.DATA.city == "Guarulhos" assert conf.OTHER == {"baz": "zaz"}