Skip to content

Commit

Permalink
Merge branch 'master' into chore/update-py-versions
Browse files Browse the repository at this point in the history
  • Loading branch information
stephrdev authored Mar 5, 2024
2 parents d32c6f9 + 43bee04 commit 588076a
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 8 deletions.
28 changes: 21 additions & 7 deletions pytest_isort/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,21 @@ def _make_path_kwargs(p):
return dict(path=Path(p)) if PYTEST_VER >= (7, 0) else dict(fspath=p)


def pytest_collect_file(path, parent):
config = parent.config
if config.option.isort and path.ext == '.py':
if not config._isort_ignore(path):
return IsortFile.from_parent(parent, **_make_path_kwargs(path))
if PYTEST_VER >= (7, 0):

def pytest_collect_file(file_path, parent):
config = parent.config
if config.option.isort and file_path.suffix == '.py':
if not config._isort_ignore(file_path):
return IsortFile.from_parent(parent, **_make_path_kwargs(file_path))

else:

def pytest_collect_file(path, parent):
config = parent.config
if config.option.isort and path.ext == '.py':
if not config._isort_ignore(path):
return IsortFile.from_parent(parent, **_make_path_kwargs(path))


def pytest_sessionfinish(session):
Expand Down Expand Up @@ -139,8 +149,12 @@ def __call__(self, path):
"""

for glob in self.ignores:
if path.fnmatch(glob):
return glob
if isinstance(path, Path):
if path.match(glob):
return glob
else:
if path.fnmatch(glob):
return glob

return False

Expand Down
3 changes: 2 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
isolated_build = true
envlist =
{py38,py39}-{pytest5,pytest6,pytest7}-{isort4,isort5}
{py310,py311}-{pytest6,pytest7}-{isort4,isort5}
{py310,py311}-{pytest6,pytest7,pytest8}-{isort4,isort5}

[gh-actions]
python =
Expand All @@ -17,6 +17,7 @@ deps =
pytest5: pytest>=5,<6
pytest6: pytest>=6,<7
pytest7: pytest>=7,<8
pytest8: pytest>=8,<9
isort4: isort>=4,<5
isort5: isort>=5,<6
allowlist_externals =
Expand Down

0 comments on commit 588076a

Please sign in to comment.