shopkeep / pytest-black

pytest plugin to enable formatting checks with black
MIT License
53 stars 23 forks source link

0.3.12: `PytestDeprecationWarning` warnings #58

Open kloczek opened 2 years ago

kloczek commented 2 years ago

On testing other sphinx-reredirects module I found some warnings whcih seems are related to pytest-black code

+ PYTHONPATH=/home/tkloczko/rpmbuild/BUILDROOT/python-sphinx-reredirects-0.1.0-2.fc35.x86_64/usr/lib64/python3.8/site-packages:/home/tkloczko/rpmbuild/BUILDROOT/python-sphinx-reredirects-0.1.0-2.fc35.x86_64/usr/lib/python3.8/site-packages
+ /usr/bin/pytest -ra --black
=========================================================================== test session starts ============================================================================
platform linux -- Python 3.8.13, pytest-7.1.2, pluggy-1.0.0
rootdir: /home/tkloczko/rpmbuild/BUILD/sphinx-reredirects-v0.1.0
plugins: anyio-3.5.0, tornasync-0.6.0.post2, timeout-2.1.0, cov-3.0.0, black-0.3.12
collected 3 items

setup.py F                                                                                                                                                           [ 33%]
docs/conf.py F                                                                                                                                                       [ 66%]
sphinx_reredirects/__init__.py F                                                                                                                                     [100%]

================================================================================= FAILURES =================================================================================
____________________________________________________________________________ Black format check ____________________________________________________________________________
--- /home/tkloczko/rpmbuild/BUILD/sphinx-reredirects-v0.1.0/setup.py    2021-04-26 09:36:12 +0000
+++ /home/tkloczko/rpmbuild/BUILD/sphinx-reredirects-v0.1.0/setup.py    2022-05-18 11:45:10.372511 +0000
@@ -1,35 +1,30 @@
 from setuptools import setup

 setup(
-    name='sphinx_reredirects',
-    version='0.0.1',
-    url='https://gitlab.com/documatt/sphinx-reredirects',
-    license='BSD3',
-    author='Matt from Documatt',
-    author_email='matt@documatt.com',
-    description='Handles redirects for moved pages in Sphinx documentation '
-    'projects',
-    long_description=open('README.rst', encoding='utf-8').read(),
-    long_description_content_type='text/x-rst',
-    packages=['sphinx_reredirects'],
-    install_requires=[
-        'sphinx'
-    ],
-    setup_requires=[
-        'wheel'
-    ],
+    name="sphinx_reredirects",
+    version="0.0.1",
+    url="https://gitlab.com/documatt/sphinx-reredirects",
+    license="BSD3",
+    author="Matt from Documatt",
+    author_email="matt@documatt.com",
+    description="Handles redirects for moved pages in Sphinx documentation " "projects",
+    long_description=open("README.rst", encoding="utf-8").read(),
+    long_description_content_type="text/x-rst",
+    packages=["sphinx_reredirects"],
+    install_requires=["sphinx"],
+    setup_requires=["wheel"],
     classifiers=[
-        'Development Status :: 5 - Production/Stable',
-        'Environment :: Console',
-        'Environment :: Web Environment',
-        'Framework :: Sphinx :: Extension',
-        'Intended Audience :: Developers',
-        'License :: OSI Approved :: BSD License',
-        'Operating System :: OS Independent',
-        'Programming Language :: Python',
-        'Programming Language :: Python :: 3',
-        'Topic :: Documentation',
-        'Topic :: Documentation :: Sphinx',
-        'Topic :: Utilities',
+        "Development Status :: 5 - Production/Stable",
+        "Environment :: Console",
+        "Environment :: Web Environment",
+        "Framework :: Sphinx :: Extension",
+        "Intended Audience :: Developers",
+        "License :: OSI Approved :: BSD License",
+        "Operating System :: OS Independent",
+        "Programming Language :: Python",
+        "Programming Language :: Python :: 3",
+        "Topic :: Documentation",
+        "Topic :: Documentation :: Sphinx",
+        "Topic :: Utilities",
     ],
 )

[..]

============================================================================= warnings summary =============================================================================
../../../../../usr/lib/python3.8/site-packages/_pytest/nodes.py:146
../../../../../usr/lib/python3.8/site-packages/_pytest/nodes.py:146
../../../../../usr/lib/python3.8/site-packages/_pytest/nodes.py:146
  /usr/lib/python3.8/site-packages/_pytest/nodes.py:146: PytestDeprecationWarning: <class 'pytest_black.BlackItem'> 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(

../../../../../usr/lib/python3.8/site-packages/_pytest/nodes.py:264
../../../../../usr/lib/python3.8/site-packages/_pytest/nodes.py:264
../../../../../usr/lib/python3.8/site-packages/_pytest/nodes.py:264
  /usr/lib/python3.8/site-packages/_pytest/nodes.py:264: PytestRemovedIn8Warning: The (fspath: py.path.local) argument to BlackItem 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
    return cls._create(parent=parent, **kw)

../../../../../usr/lib/python3.8/site-packages/_pytest/nodes.py:708
  /usr/lib/python3.8/site-packages/_pytest/nodes.py:708: PytestWarning: BlackItem 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(

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
========================================================================= short test summary info ==========================================================================
FAILED setup.py::BLACK
FAILED docs/conf.py::BLACK
FAILED sphinx_reredirects/__init__.py::BLACK
====================================================================== 3 failed, 7 warnings in 0.86s =======================================================================
rbebb commented 2 years ago

I'm running into the same problem