Skip to content

Lint tests are failing, unpinned ruff version is used for ruff check #1575

@krassowski

Description

@krassowski

It appears that the checks introduced in newer ruff versions are making CI on PRs very red, as noticed in #1574. The version in pre-commit config is pinned so contributors do not see it when sending PRs, but the version used by hatch fmt is not pinned (but should be aligned with the one used by pre-commit!).

+ hatch fmt
Creating environment: hatch-static-analysis
Checking dependencies
Syncing dependencies
cmd [1] | ruff check --config /home/runner/.local/share/hatch/env/.internal/hatch-static-analysis/.config/horQbOoS/pyproject.toml --fix .
warning: Invalid rule code provided to `# noqa` at jupyter_server/services/contents/largefilemanager.py:154: ASYNC101
PLC0415 `import` should be at the top-level of a file
   --> docs/source/conf.py:398:5
    |
397 |     # Generate full-config docs.
398 |     from jupyter_server.serverapp import ServerApp
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
399 |
400 |     destination = os.path.join(HERE, "other/full-config.rst")
    |

SIM103 Return the condition `action == "read"` directly
  --> examples/authorization/jupyter_nbclassic_readonly_config.py:11:9
   |
 9 |       def is_authorized(self, handler, user, action, resource):
10 |           """Only allows `read` operations."""
11 | /         if action != "read":
12 | |             return False
300 |     with warnings.catch_warnings():
301 |         warnings.simplefilter("ignore")
302 |         from jupyter_server.terminal import initialize
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
303 |         from jupyter_server.terminal.api_handlers import TerminalRootHandler
304 |         from jupyter_server.terminal.handlers import TermSocket
    |

PLC0415 `import` should be at the top-level of a file
   --> tests/test_terminal.py:303:9
    |
301 |         warnings.simplefilter("ignore")
302 |         from jupyter_server.terminal import initialize
303 |         from jupyter_server.terminal.api_handlers import TerminalRootHandler
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
304 |         from jupyter_server.terminal.handlers import TermSocket
305 |         from jupyter_server.terminal.terminalmanager import TerminalManager
    |

PLC0415 `import` should be at the top-level of a file
   --> tests/test_terminal.py:304:9
    |
302 |         from jupyter_server.terminal import initialize
303 |         from jupyter_server.terminal.api_handlers import TerminalRootHandler
304 |         from jupyter_server.terminal.handlers import TermSocket
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
305 |         from jupyter_server.terminal.terminalmanager import TerminalManager
    |

PLC0415 `import` should be at the top-level of a file
   --> tests/test_terminal.py:305:9
    |
303 |         from jupyter_server.terminal.api_handlers import TerminalRootHandler
304 |         from jupyter_server.terminal.handlers import TermSocket
305 |         from jupyter_server.terminal.terminalmanager import TerminalManager
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |

PLC0415 `import` should be at the top-level of a file
   --> tests/unix_sockets/test_serverapp_integration.py:196:5
    |
194 |     # Start a server in another process
195 |     # Stop that server
196 |     import subprocess
    |     ^^^^^^^^^^^^^^^^^
197 |
198 |     from jupyter_client.connect import LocalPortCache
    |

PLC0415 `import` should be at the top-level of a file
   --> tests/unix_sockets/test_serverapp_integration.py:198:5
    |
196 |     import subprocess
197 |
198 |     from jupyter_client.connect import LocalPortCache
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
199 |
200 |     port = LocalPortCache().find_available_port("localhost")
    |

PLC0415 `import` should be at the top-level of a file
   --> tests/unix_sockets/test_serverapp_integration.py:221:5
    |
219 |     # Start a server in another process
220 |     # Stop that server
221 |     import subprocess
    |     ^^^^^^^^^^^^^^^^^
222 |
223 |     from jupyter_client.connect import LocalPortCache
    |

PLC0415 `import` should be at the top-level of a file
   --> tests/unix_sockets/test_serverapp_integration.py:223:5
    |
221 |     import subprocess
222 |
223 |     from jupyter_client.connect import LocalPortCache
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
224 |
225 |     port = LocalPortCache().find_available_port("localhost")
    |

SIM103 Return the negated condition directly
  --> tests/utils.py:30:9
   |
28 |           if expected_code != e.status_code:
29 |               return False
30 | /         if expected_message is not None and expected_message != str(e):
31 | |             return False
32 | |         return True
   | |___________________^
33 |       elif any(
34 |           [
   |
help: Inline condition

Found 137 errors (51 fixed, 86 remaining).
No fixes available (51 hidden fixes can be enabled with the `--unsafe-fixes` option).

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions