Skip to content

Commit

Permalink
Merge pull request #64 from MRigal/patch-1
Browse files Browse the repository at this point in the history
Fix pytest deprecation warning from_parent
  • Loading branch information
tholo authored Apr 23, 2020
2 parents c485d5e + b10e5d9 commit 92de336
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions pytest_flake8.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,23 @@ def pytest_collect_file(path, parent):
if config.option.flake8 and path.ext in config._flake8exts:
flake8ignore = config._flake8ignore(path)
if flake8ignore is not None:
return Flake8Item(
path,
parent,
flake8ignore=flake8ignore,
maxlength=config._flake8maxlen,
maxcomplexity=config._flake8maxcomplexity,
showshource=config._flake8showshource,
statistics=config._flake8statistics)
if hasattr(Flake8Item, "from_parent"):
item = Flake8Item.from_parent(parent, fspath=path)
item.flake8ignore = flake8ignore
item.maxlength = config._flake8maxlen
item.maxcomplexity = config._flake8maxcomplexity
item.showshource = config._flake8showshource
item.statistics = config._flake8statistics
return item
else:
return Flake8Item(
path,
parent,
flake8ignore=flake8ignore,
maxlength=config._flake8maxlen,
maxcomplexity=config._flake8maxcomplexity,
showshource=config._flake8showshource,
statistics=config._flake8statistics)


def pytest_unconfigure(config):
Expand Down

0 comments on commit 92de336

Please sign in to comment.