]> git.ipfire.org Git - thirdparty/starlette.git/commitdiff
Added type annotations to test_config.py (#2475)
authorScirlat Danut <danut.scirlat@gmail.com>
Sun, 4 Feb 2024 18:33:06 +0000 (20:33 +0200)
committerGitHub <noreply@github.com>
Sun, 4 Feb 2024 18:33:06 +0000 (18:33 +0000)
* added type annotations to test_config.py

* Apply suggestions from code review

---------

Co-authored-by: Scirlat Danut <scirlatdanut@scirlats-mini.lan>
Co-authored-by: Marcelo Trylesinski <marcelotryle@gmail.com>
tests/test_config.py

index f7b294c7ae76b5c2d9f55ca00a62d16a60722218..4974ffdb01569e4f9a452fddca2f99a9ba03bafe 100644 (file)
@@ -1,4 +1,5 @@
 import os
+import typing
 from pathlib import Path
 from typing import Any, Optional
 
@@ -39,7 +40,7 @@ def test_config_types() -> None:
         config("INT_DEFAULT_STR", cast=int, default="true")
 
 
-def test_config(tmpdir, monkeypatch):
+def test_config(tmpdir: Path, monkeypatch: pytest.MonkeyPatch) -> None:
     path = os.path.join(tmpdir, ".env")
     with open(path, "w") as file:
         file.write("# Do not commit to source control\n")
@@ -52,7 +53,7 @@ def test_config(tmpdir, monkeypatch):
 
     config = Config(path, environ={"DEBUG": "true"})
 
-    def cast_to_int(v) -> int:
+    def cast_to_int(v: typing.Any) -> int:
         return int(v)
 
     DEBUG = config("DEBUG", cast=bool)
@@ -104,14 +105,14 @@ def test_config(tmpdir, monkeypatch):
         config.get("BOOL_AS_INT", cast=bool)
 
 
-def test_missing_env_file_raises(tmpdir):
+def test_missing_env_file_raises(tmpdir: Path) -> None:
     path = os.path.join(tmpdir, ".env")
 
     with pytest.raises(FileNotFoundError, match=f"Config file '{path}' not found."):
         Config(path)
 
 
-def test_environ():
+def test_environ() -> None:
     environ = Environ()
 
     # We can mutate the environ at this point.
@@ -136,7 +137,7 @@ def test_environ():
     assert len(environ) == len(os.environ)
 
 
-def test_config_with_env_prefix(tmpdir, monkeypatch):
+def test_config_with_env_prefix(tmpdir: Path, monkeypatch: pytest.MonkeyPatch) -> None:
     config = Config(
         environ={"APP_DEBUG": "value", "ENVIRONMENT": "dev"}, env_prefix="APP_"
     )