Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pytest-flake8 deprecation warning from Pytest #285

Closed
akaihola opened this issue Feb 12, 2022 · 11 comments
Closed

pytest-flake8 deprecation warning from Pytest #285

akaihola opened this issue Feb 12, 2022 · 11 comments
Assignees
Labels
enhancement New feature or request maybe invalid? Can't reproduce, or seems already fixed, or need more information
Milestone

Comments

@akaihola
Copy link
Owner

In recent test builds we have:

_pytest/nodes.py:146: 43 warnings
  _pytest/nodes.py:146: PytestDeprecationWarning: <class 'pytest_flake8.Flake8Item'> is not using a cooperative constructor and only takes {'fspath', 'parent'}.
  See https://docs.pytest.org/en/stable/deprecations.html#constructors-of-custom-pytest-node-subclasses-should-take-kwargs for more details.
    warnings.warn(

_pytest/nodes.py:672: 43 warnings
  _pytest/nodes.py:672: PytestRemovedIn8Warning: The (fspath: py.path.local) argument to Flake8Item is deprecated. Please use the (path: pathlib.Path) argument instead.
  See https://docs.pytest.org/en/latest/deprecations.html#fspath-argument-for-node-constructors-replaced-with-pathlib-path
    super().__init__(

_pytest/nodes.py:708
  _pytest/nodes.py:708: PytestWarning: Flake8Item is an Item subclass and should not be a collector, however its bases File are collectors.
  Please split the Collectors and the Item into separate node types.
  Pytest Doc example: https://docs.pytest.org/en/latest/example/nonpython.html
  example pull request on a plugin: https://github.com/asmeurer/pytest-flakes/pull/40/
    warnings.warn(

Maybe there's an update to pytest-flake8 which updates this behavior and silences the warning?

@akaihola akaihola added enhancement New feature or request good first issue Good for newcomers labels Feb 12, 2022
@akaihola akaihola added this to the 1.4.2 milestone Feb 12, 2022
@akaihola akaihola self-assigned this Feb 12, 2022
@RishiKumarRay
Copy link

I have read somewhere , a recent update few days back is causing this errors

@RishiKumarRay
Copy link

RishiKumarRay commented Feb 12, 2022

@akaihola It is happening with pytest = 7.0.0 update

@akaihola
Copy link
Owner Author

Thanks @RishiKumarRay! I guess this is about tholo/pytest-flake8#83 then.

@RishiKumarRay
Copy link

@akaihola should we fix the version of pytest maybe ?

@akaihola
Copy link
Owner Author

I would rather try to contribute a fix to pytest-flake8. And this is just a deprecation warning so far, so we can afford to wait for some time for the contribution to get through. The only downside is the warning appearing in our builds, but that's not too dangerous. Or what do you think?

@RishiKumarRay
Copy link

@akaihola i totally agree with you we can wait as its just a warning

@akaihola
Copy link
Owner Author

But since we do need to fix the same problem in akaihola/pytest-darker#7, we'll probably learn how to fix pytest-flake8 as well.

@akaihola akaihola modified the milestones: 1.4.2, 1.5.0 Feb 18, 2022
@akaihola
Copy link
Owner Author

Moving this to milestone 1.5.0, there are a plenty of bugfixes and documentation improvements coming up for a 1.4.2 bugfix release already.

@akaihola
Copy link
Owner Author

In tholo/pytest-flake8#83, @jaraco mentions:

See jaraco/pytest-checkdocs#9 and jaraco/pytest-perf#5 for approaches I used to fix this issue.

He also writes:

See pytest-dev/pytest#8435 for background

I guess I'll take a look at those and copy his solution to akaihola/pytest-darker#7 and maybe try to contribute it to tholo/pytest-flake8#83 as well.

@akaihola
Copy link
Owner Author

akaihola commented Apr 1, 2022

With pytest-flake8==1.1.0 and pytest==7.0.0 I used to get these:

_pytest/nodes.py:146
  _pytest/nodes.py:146: PytestDeprecationWarning: <class 'pytest_flake8.Flake8Item'> is not using a cooperative constructor and only takes {'fspath', 'parent'}.
  See https://docs.pytest.org/en/stable/deprecations.html#constructors-of-custom-pytest-node-subclasses-should-take-kwargs for more details.
    warnings.warn(

_pytest/nodes.py:686
  _pytest/nodes.py:686: PytestRemovedIn8Warning: The (fspath: py.path.local) argument to Flake8Item is deprecated. Please use the (path: pathlib.Path) argument instead.
  See https://docs.pytest.org/en/latest/deprecations.html#fspath-argument-for-node-constructors-replaced-with-pathlib-path
    super().__init__(

After upgrading to pytest==7.1.1, I additionally see this one:

_pytest/nodes.py:708
  _pytest/nodes.py:708: PytestWarning: Flake8Item is an Item subclass and should not be a collector, however its bases File are collectors.
  Please split the Collectors and the Item into separate node types.
  Pytest Doc example: https://docs.pytest.org/en/latest/example/nonpython.html
  example pull request on a plugin: https://github.com/asmeurer/pytest-flakes/pull/40/
    warnings.warn(

But after upgrading to pytest-flake8==1.1.1 they all disappear.

But tholo/pytest-flake8#83 is still Open – was the fix applied in some other PR?

@akaihola akaihola modified the milestones: 1.5.0, 1.5.1 Apr 5, 2022
@akaihola
Copy link
Owner Author

In #361 we're changing the CI setup so Flake8 is run directly in its own workflow instead of through the Pytest plugin. That should make it unnecessary to address this issue. So we could close this issue, right @RishiKumarRay?

@akaihola akaihola added maybe invalid? Can't reproduce, or seems already fixed, or need more information and removed good first issue Good for newcomers labels Apr 27, 2022
@akaihola akaihola modified the milestones: 1.5.1, 1.6.0 Sep 13, 2022
@akaihola akaihola modified the milestones: 1.6.0, 1.6.1 Dec 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request maybe invalid? Can't reproduce, or seems already fixed, or need more information
Projects
None yet
Development

No branches or pull requests

2 participants