Skip to content

Commit

Permalink
Use more specific Mypy ignore comments
Browse files Browse the repository at this point in the history
`# type: ignore` -> `type: ignore[attr-defined]`
  • Loading branch information
br3ndonland committed Sep 4, 2020
1 parent 68d86cf commit f2b5419
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions tests/test_start.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ def test_set_app_module_asgi(
"""Test `start.set_app_module` using module path to base ASGI app."""
monkeypatch.setenv("APP_MODULE", "inboard.app.base.main:app")
start.set_app_module(logger=mock_logger)
mock_logger.debug.assert_called_once_with( # type: ignore
mock_logger.debug.assert_called_once_with( # type: ignore[attr-defined]
"App module set to inboard.app.base.main:app."
)

Expand All @@ -168,7 +168,7 @@ def test_set_app_module_fastapi(
"""Test `start.set_app_module` using module path to FastAPI app."""
monkeypatch.setenv("APP_MODULE", "inboard.app.fastapibase.main:app")
start.set_app_module(logger=mock_logger)
mock_logger.debug.assert_called_once_with( # type: ignore
mock_logger.debug.assert_called_once_with( # type: ignore[attr-defined]
"App module set to inboard.app.fastapibase.main:app."
)

Expand All @@ -178,7 +178,7 @@ def test_set_app_module_starlette(
"""Test `start.set_app_module` using module path to Starlette app."""
monkeypatch.setenv("APP_MODULE", "inboard.app.starlettebase.main:app")
start.set_app_module(logger=mock_logger)
mock_logger.debug.assert_called_once_with( # type: ignore
mock_logger.debug.assert_called_once_with( # type: ignore[attr-defined]
"App module set to inboard.app.starlettebase.main:app."
)

Expand All @@ -192,7 +192,7 @@ def test_set_app_module_custom_asgi(
monkeypatch.syspath_prepend(app_module_tmp_path)
monkeypatch.setenv("APP_MODULE", "tmp_app.base.main:app")
start.set_app_module(logger=mock_logger)
mock_logger.debug.assert_called_once_with( # type: ignore
mock_logger.debug.assert_called_once_with( # type: ignore[attr-defined]
"App module set to tmp_app.base.main:app."
)

Expand All @@ -206,7 +206,7 @@ def test_set_app_module_custom_fastapi(
monkeypatch.syspath_prepend(app_module_tmp_path)
monkeypatch.setenv("APP_MODULE", "tmp_app.fastapibase.main:app")
start.set_app_module(logger=mock_logger)
mock_logger.debug.assert_called_once_with( # type: ignore
mock_logger.debug.assert_called_once_with( # type: ignore[attr-defined]
"App module set to tmp_app.fastapibase.main:app."
)

Expand All @@ -220,7 +220,7 @@ def test_set_app_module_custom_starlette(
monkeypatch.syspath_prepend(app_module_tmp_path)
monkeypatch.setenv("APP_MODULE", "tmp_app.starlettebase.main:app")
start.set_app_module(logger=mock_logger)
mock_logger.debug.assert_called_once_with( # type: ignore
mock_logger.debug.assert_called_once_with( # type: ignore[attr-defined]
"App module set to tmp_app.starlettebase.main:app."
)

Expand All @@ -237,7 +237,7 @@ def test_set_app_module_incorrect(
logger_error_msg = "Error when setting app module:"
incorrect_module_msg = f"No module named {incorrect_module}"
start.set_app_module(logger=mock_logger)
mock_logger.debug.assert_called_once_with( # type: ignore
mock_logger.debug.assert_called_once_with( # type: ignore[attr-defined]
f"{logger_error_msg} {incorrect_module_msg}."
)

Expand All @@ -257,7 +257,7 @@ def test_run_pre_start_script_py(
"""Test `start.run_pre_start_script` using temporary Python pre-start script."""
monkeypatch.setenv("PRE_START_PATH", str(pre_start_script_tmp_py))
start.run_pre_start_script(logger=mock_logger)
mock_logger.debug.assert_has_calls( # type: ignore
mock_logger.debug.assert_has_calls( # type: ignore[attr-defined]
calls=[
mocker.call("Checking for pre-start script."),
mocker.call(
Expand All @@ -279,7 +279,7 @@ def test_run_pre_start_script_sh(
"""Test `start.run_pre_start_script` using temporary pre-start shell script."""
monkeypatch.setenv("PRE_START_PATH", str(pre_start_script_tmp_sh))
start.run_pre_start_script(logger=mock_logger)
mock_logger.debug.assert_has_calls( # type: ignore
mock_logger.debug.assert_has_calls( # type: ignore[attr-defined]
calls=[
mocker.call("Checking for pre-start script."),
mocker.call(
Expand All @@ -300,7 +300,7 @@ def test_run_pre_start_script_no_file(
"""Test `start.run_pre_start_script` with an incorrect file path."""
monkeypatch.setenv("PRE_START_PATH", "/no/file/here")
start.run_pre_start_script(logger=mock_logger)
mock_logger.debug.assert_has_calls( # type: ignore
mock_logger.debug.assert_has_calls( # type: ignore[attr-defined]
calls=[
mocker.call("Checking for pre-start script."),
mocker.call("No pre-start script found."),
Expand Down Expand Up @@ -341,7 +341,7 @@ def test_start_server_uvicorn(
logging_conf_dict=logging_conf_dict,
with_reload=False,
)
mock_logger.debug.assert_called_once_with("Running Uvicorn with Gunicorn.") # type: ignore # noqa: E501
mock_logger.debug.assert_called_once_with("Running Uvicorn with Gunicorn.") # type: ignore[attr-defined] # noqa: E501

@pytest.mark.parametrize(
"app_module",
Expand Down Expand Up @@ -370,7 +370,7 @@ def test_start_server_uvicorn_gunicorn(
logger=mock_logger,
logging_conf_dict=logging_conf_dict,
)
mock_logger.debug.assert_called_once_with("Running Uvicorn with Gunicorn.") # type: ignore # noqa: E501
mock_logger.debug.assert_called_once_with("Running Uvicorn with Gunicorn.") # type: ignore[attr-defined] # noqa: E501

def test_start_server_uvicorn_incorrect_module(
self,
Expand All @@ -393,7 +393,7 @@ def test_start_server_uvicorn_incorrect_module(
)
logger_error_msg = "Error when starting server with start script:"
module_error_msg = "No module named incorrect.base.main:app"
mock_logger.debug.assert_has_calls( # type: ignore
mock_logger.debug.assert_has_calls( # type: ignore[attr-defined]
calls=[
mocker.call("Running Uvicorn without Gunicorn."),
mocker.call(f"{logger_error_msg} {module_error_msg}"),
Expand Down Expand Up @@ -432,6 +432,6 @@ def test_start_server_uvicorn_incorrect_process_manager(
process_error_msg = (
"Process manager needs to be either uvicorn or gunicorn."
)
mock_logger.debug.assert_called_once_with( # type: ignore
mock_logger.debug.assert_called_once_with( # type: ignore[attr-defined]
f"{logger_error_msg} {process_error_msg}"
)

0 comments on commit f2b5419

Please sign in to comment.