Skip to content

Commit

Permalink
Fix pytest deprecation warning from_parent
Browse files Browse the repository at this point in the history
Fixes #63
  • Loading branch information
MRigal authored Apr 23, 2020
1 parent c485d5e commit b10e5d9
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 b10e5d9

Please sign in to comment.