deprecation warning for not catch lowercase env var (#2344)

This commit is contained in:
Zhiwei
2021-12-26 12:47:15 -07:00
committed by GitHub
parent 3eae00898d
commit 371985d129
2 changed files with 41 additions and 18 deletions

View File

@@ -221,9 +221,12 @@ class Config(dict, metaclass=DescriptorMeta):
`See user guide re: config
<https://sanicframework.org/guide/deployment/configuration.html>`__
"""
lower_case_var_found = False
for key, value in environ.items():
if not key.startswith(prefix):
continue
if not key.isupper():
lower_case_var_found = True
_, config_key = key.split(prefix, 1)
@@ -233,6 +236,12 @@ class Config(dict, metaclass=DescriptorMeta):
break
except ValueError:
pass
if lower_case_var_found:
deprecation(
"Lowercase environment variables will not be "
"loaded into Sanic config beginning in v22.9.",
22.9,
)
def update_config(self, config: Union[bytes, str, dict, Any]):
"""