diff --git a/src/flake8_requirements/checker.py b/src/flake8_requirements/checker.py index f71d8e5..92b4442 100644 --- a/src/flake8_requirements/checker.py +++ b/src/flake8_requirements/checker.py @@ -18,7 +18,7 @@ from .modules import STDLIB_PY3 # NOTE: Changing this number will alter package version as well. -__version__ = "1.6.1" +__version__ = "1.6.2" __license__ = "MIT" LOG = getLogger('flake8.plugin.requirements') @@ -566,6 +566,10 @@ def get_pyproject_toml_poetry_requirements(self): poetry.get('dependencies', ()))) requirements.extend(parse_requirements( poetry.get('dev-dependencies', ()))) + # Collect dependencies from groups (since poetry-1.2). + for _, group in poetry.get('group', {}).items(): + requirements.extend(parse_requirements( + group.get('dependencies', ()))) return requirements @classmethod diff --git a/test/test_poetry.py b/test/test_poetry.py index b94da42..61d3652 100644 --- a/test/test_poetry.py +++ b/test/test_poetry.py @@ -51,3 +51,18 @@ def test_3rd_party(self): checker = Flake8Checker(None, None) mods = checker.get_mods_3rd_party() self.assertEqual(mods, ModuleSet({"tools": {}, "dev_tools": {}})) + + def test_3rd_party_groups(self): + content = "[tool.poetry.dependencies]\ntools='1.0'\n" + content += "[tool.poetry.group.dev.dependencies]\ndev-tools='1.0'\n" + + with mock.patch(builtins_open, mock.mock_open()) as m: + m.side_effect = ( + IOError("No such file or directory: 'setup.py'"), + IOError("No such file or directory: 'setup.cfg'"), + mock.mock_open(read_data=content).return_value, + ) + + checker = Flake8Checker(None, None) + mods = checker.get_mods_3rd_party() + self.assertEqual(mods, ModuleSet({"tools": {}, "dev_tools": {}}))