]> git.ipfire.org Git - thirdparty/httpx.git/commitdiff
Typing: enable strict_equality (#2480)
authorMartijn Pieters <mj@zopatista.com>
Fri, 2 Dec 2022 08:45:28 +0000 (08:45 +0000)
committerGitHub <noreply@github.com>
Fri, 2 Dec 2022 08:45:28 +0000 (08:45 +0000)
- ignore mypy when it comes to comparing an IntEnum member with an int
- Correct type hint for `test_wsgi_server_port`'s `expected_server_port`
  parameter.

Co-authored-by: Tom Christie <tom@tomchristie.com>
setup.cfg
tests/test_status_codes.py
tests/test_wsgi.py

index 58cb1d226cce6a5e6fd5b986a803f6c749dd44a0..385e71c21f1e6a9db080c0cbcd7ea3594ad70177 100644 (file)
--- a/setup.cfg
+++ b/setup.cfg
@@ -18,6 +18,7 @@ strict_concatenate = True
 disallow_incomplete_defs = True
 no_implicit_reexport = True
 warn_return_any = True
+strict_equality = True
 
 [mypy-tests.*]
 disallow_untyped_defs = False
index f253cecd68ceeb876433142b38deb8f132983528..13314db788b536bea62c0b57e5c50a8e05ef713c 100644 (file)
@@ -2,7 +2,8 @@ import httpx
 
 
 def test_status_code_as_int():
-    assert httpx.codes.NOT_FOUND == 404
+    # mypy doesn't (yet) recognize that IntEnum members are ints, so ignore it here
+    assert httpx.codes.NOT_FOUND == 404  # type: ignore[comparison-overlap]
     assert str(httpx.codes.NOT_FOUND) == "404"
 
 
index c1439d7bcd713f06ab4d7613bb15cf6619ce0043..94e5643d4cd77975c1285830ab075d416cb42758 100644 (file)
@@ -144,7 +144,7 @@ def test_logging():
         pytest.param("http://www.example.org:8000", "8000", id="explicit-port"),
     ],
 )
-def test_wsgi_server_port(url: str, expected_server_port: int) -> None:
+def test_wsgi_server_port(url: str, expected_server_port: str) -> None:
     """
     SERVER_PORT is populated correctly from the requested URL.
     """