From f2b5419e8c97ca32a86f2830defb4dc873ef293a Mon Sep 17 00:00:00 2001 From: Brendon Smith Date: Fri, 4 Sep 2020 16:34:02 -0400 Subject: [PATCH] Use more specific Mypy ignore comments `# type: ignore` -> `type: ignore[attr-defined]` --- tests/test_start.py | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/tests/test_start.py b/tests/test_start.py index 6cecc01..faaf2fb 100644 --- a/tests/test_start.py +++ b/tests/test_start.py @@ -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." ) @@ -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." ) @@ -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." ) @@ -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." ) @@ -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." ) @@ -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." ) @@ -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}." ) @@ -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( @@ -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( @@ -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."), @@ -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", @@ -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, @@ -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}"), @@ -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}" )