Typing: enable strict_equality (#2480)

- 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>
This commit is contained in:
Martijn Pieters 2022-12-02 08:45:28 +00:00 committed by GitHub
parent 5098f47444
commit 884a69a902
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 4 additions and 2 deletions

View File

@ -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

View 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"

View 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.
"""