Skip to content

Update Sphinx Lint and fix unnecessary parentheses in :func:s #123960

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

Merged
merged 1 commit into from
Sep 11, 2024

Conversation

hugovk
Copy link
Member

@hugovk hugovk commented Sep 11, 2024

We've just released Sphinx Lint 1.0.0:

The main addition is a check for unnecessary parentheses in :func:s, and it finds two occurences in main:

Doc/library/annotationlib.rst:318: Unnecessary parentheses in ':func:`eval()`' (unnecessary-parentheses)
Misc/NEWS.d/next/Library/2024-08-23-22-01-30.gh-issue-76960.vsANPu.rst:2: Unnecessary parentheses in ':func:`!urljoin()`' (unnecessary-parentheses)

This PR updates pre-commit and fixes these.

Also update the other pre-commit hooks, except I only updated Ruff to v0.4.10, because v0.6.4 reports some F811 warnings, some of which I think are intentional:

Details
Run Ruff (lint) on Lib/test/.............................................Failed
- hook id: ruff
- exit code: 1

Lib/test/pickletester.py:4348:7: F811 Redefinition of unused `SimpleNewObj` from line 3164
     |
4346 |     __slots__ = ["foo"]
4347 |
4348 | class SimpleNewObj(int):
     |       ^^^^^^^^^^^^ F811
4349 |     def __init__(self, *args, **kwargs):
4350 |         # raise an error, to make sure this isn't called
     |
     = help: Remove definition: `SimpleNewObj`

Lib/test/test_bz2.py:480:46: F811 Redefinition of unused `f` from line 479
    |
478 |     def testContextProtocol(self):
479 |         f = None
480 |         with BZ2File(self.filename, "wb") as f:
    |                                              ^ F811
481 |             f.write(b"xxx")
482 |         f = BZ2File(self.filename, "rb")
    |
    = help: Remove definition: `f`

Lib/test/test_contextlib.py:448:54: F811 Redefinition of unused `f` from line 447
    |
446 |         try:
447 |             f = None
448 |             with open(tfn, "w", encoding="utf-8") as f:
    |                                                      ^ F811
449 |                 self.assertFalse(f.closed)
450 |                 f.write("Booh\n")
    |
    = help: Remove definition: `f`

Lib/test/test_io.py:643:64: F811 Redefinition of unused `f` from line 642
    |
641 |         for bufsize in (0, 100):
642 |             f = None
643 |             with self.open(os_helper.TESTFN, "wb", bufsize) as f:
    |                                                                ^ F811
644 |                 f.write(b"xxx")
645 |             self.assertEqual(f.closed, True)
    |
    = help: Remove definition: `f`

Lib/test/test_os.py:3176:16: F811 Redefinition of unused `ctypes` from line 3175
     |
3174 |         nt = import_helper.import_module('nt')
3175 |         ctypes = import_helper.import_module('ctypes')
3176 |         import ctypes.wintypes
     |                ^^^^^^^^^^^^^^^ F811
3177 |
3178 |         kernel = ctypes.WinDLL('Kernel32.dll', use_last_error=True)
     |
     = help: Remove definition: `ctypes`

Lib/test/test_with.py:256:49: F811 Redefinition of unused `foo` from line 255
    |
254 |     def testInlineGeneratorBoundToExistingVariable(self):
255 |         foo = None
256 |         with mock_contextmanager_generator() as foo:
    |                                                 ^^^ F811
257 |             self.assertInWithGeneratorInvariants(foo)
258 |         self.assertAfterWithGeneratorInvariantsNoError(foo)
    |
    = help: Remove definition: `foo`

Found 6 errors.

We can address those later (perhaps at the sprint).


📚 Documentation preview 📚: https://cpython-previews--123960.org.readthedocs.build/

@hugovk hugovk merged commit eb169f4 into python:main Sep 11, 2024
28 checks passed
@hugovk hugovk deleted the update-pre-commit branch September 11, 2024 18:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants