diff --git a/autohooks/hooks.py b/autohooks/hooks.py index 835e944a..3f4687c2 100644 --- a/autohooks/hooks.py +++ b/autohooks/hooks.py @@ -72,7 +72,7 @@ def read_mode(self) -> Mode: if shebang == PYTHON3_SHEBANG: return Mode.PYTHONPATH - if shebang == POETRY_SHEBANG: + if shebang.startswith(POETRY_SHEBANG): return Mode.POETRY if shebang == PIPENV_SHEBANG: return Mode.PIPENV diff --git a/tests/test_hooks.py b/tests/test_hooks.py index 51a3ce99..127808c6 100644 --- a/tests/test_hooks.py +++ b/tests/test_hooks.py @@ -173,6 +173,12 @@ def test_poetry_mode(self): self.assertEqual(pre_commit_hook.read_mode(), Mode.POETRY) + def test_poetry_mode_with_python3(self): + path = FakeReadPath(f"#!{POETRY_SHEBANG}3") + pre_commit_hook = PreCommitHook(path) + + self.assertEqual(pre_commit_hook.read_mode(), Mode.POETRY) + def test_pipenv_multiline_mode(self): path = FakeReadPath(f"#!{PIPENV_MULTILINE_SHEBANG}") pre_commit_hook = PreCommitHook(path)