From 7433a8926f2e586fcc732a8bbb58aa197d13c49d Mon Sep 17 00:00:00 2001 From: Marc Cataford Date: Mon, 16 Sep 2024 08:20:43 -0400 Subject: [PATCH] build: linting exception defaults --- .pylintrc | 8 -------- main.py | 4 ++-- pyproject.toml | 9 +++++++++ test.py | 16 ++++++++-------- 4 files changed, 19 insertions(+), 18 deletions(-) delete mode 100644 .pylintrc diff --git a/.pylintrc b/.pylintrc deleted file mode 100644 index b1bbe00..0000000 --- a/.pylintrc +++ /dev/null @@ -1,8 +0,0 @@ -[MESSAGES CONTROL] -disable=broad-except, - broad-exception-raised, - consider-using-f-string, - consider-using-with, - invalid-name, - missing-function-docstring, - missing-module-docstring, diff --git a/main.py b/main.py index 9d9ad03..a31b998 100644 --- a/main.py +++ b/main.py @@ -45,8 +45,8 @@ def get_client(token: str) -> slack_sdk.WebClient: def parse_duration(duration: str) -> int: """Parses duration descriptors of the form xdyhzm (x,y,z integers) into timestamps relative to present.""" - durationPattern = re.compile(r"(?P\d+d)?(?P\d+h)?(?P\d+m)?") - matches = durationPattern.search(duration) + duration_pattern = re.compile(r"(?P\d+d)?(?P\d+h)?(?P\d+m)?") + matches = duration_pattern.search(duration) delta = datetime.timedelta() diff --git a/pyproject.toml b/pyproject.toml index 001b44e..57f7178 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -27,3 +27,12 @@ dev = [ [project.scripts] slck = "main:run" + +[tool.pylint.main] +disable = [ + "line-too-long", + "too-few-public-methods", + "missing-function-docstring", + "missing-module-docstring", + "broad-exception-caught" +] diff --git a/test.py b/test.py index fe4cb01..a119d8c 100644 --- a/test.py +++ b/test.py @@ -8,7 +8,7 @@ from click.testing import CliRunner from main import cli, get_configuration, parse_duration -@pytest.fixture(name="with_sample_config") +@pytest.fixture(name="with_sample_config", autouse=True) def fixture_with_sample_config(tmp_path): config_path = tmp_path / "config.yml" config_path.write_text( @@ -67,7 +67,7 @@ presets: assert conf.presets["test"].emoji == ":tada:" -def test_cli_requires_text_or_preset_input(tmp_path, with_sample_config): +def test_cli_requires_text_or_preset_input(tmp_path): runner = CliRunner() result = runner.invoke(cli, ["--config", tmp_path / "config.yml"]) @@ -78,7 +78,7 @@ def test_cli_requires_text_or_preset_input(tmp_path, with_sample_config): ) -def test_cli_overrides_preset_with_text_input(with_sample_config, tmp_path): +def test_cli_overrides_preset_with_text_input(tmp_path): runner = CliRunner() mock_client = Mock() @@ -103,7 +103,7 @@ def test_cli_overrides_preset_with_text_input(with_sample_config, tmp_path): assert call_args.kwargs["profile"]["status_emoji"] == ":tada:" -def test_cli_overrides_preset_with_emoji_input(with_sample_config, tmp_path): +def test_cli_overrides_preset_with_emoji_input(tmp_path): runner = CliRunner() mock_client = Mock() @@ -129,7 +129,7 @@ def test_cli_overrides_preset_with_emoji_input(with_sample_config, tmp_path): @freezegun.freeze_time("2012-01-01") -def test_cli_overrides_preset_with_exp_input(with_sample_config, tmp_path): +def test_cli_overrides_preset_with_exp_input(tmp_path): runner = CliRunner() mock_client = Mock() @@ -158,7 +158,7 @@ def test_cli_overrides_preset_with_exp_input(with_sample_config, tmp_path): ) -def test_cli_raises_if_noexist_preset(tmp_path, with_sample_config): +def test_cli_raises_if_noexist_preset(tmp_path): runner = CliRunner() mock_client = Mock() @@ -172,7 +172,7 @@ def test_cli_raises_if_noexist_preset(tmp_path, with_sample_config): assert str(result.exception) == "Unknown preset: not-a-preset" -def test_cli_sends_request_to_slack(tmp_path, with_sample_config): +def test_cli_sends_request_to_slack(tmp_path): runner = CliRunner() mock_client = Mock() @@ -193,7 +193,7 @@ def test_cli_sends_request_to_slack(tmp_path, with_sample_config): mock_client.users_profile_set.assert_called() -def test_cli_raises_if_api_error(tmp_path, with_sample_config): +def test_cli_raises_if_api_error(tmp_path): runner = CliRunner() mock_client = Mock()