Skip to content

Commit 5b7971d

Browse files
committed
Remove unused stdlib imports and add Ruff F401
1 parent 1097b22 commit 5b7971d

12 files changed

Lines changed: 31 additions & 28 deletions

File tree

.pre-commit-config.yaml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
repos:
22
- repo: https://github.com/astral-sh/ruff-pre-commit
3-
rev: e05c5c0818279e5ac248ac9e954431ba58865e61 # frozen: v0.15.7
3+
rev: 3b3f7c3f57fe9925356faf5fe6230835138be230 # frozen: v0.15.17
44
hooks:
55
- id: ruff-check
66
name: Run Ruff (lint) on Platforms/Apple/
@@ -10,6 +10,11 @@ repos:
1010
name: Run Ruff (lint) on Doc/
1111
args: [--exit-non-zero-on-fix]
1212
files: ^Doc/
13+
- id: ruff-check
14+
name: Run Ruff (lint) on Lib/
15+
args: [--exit-non-zero-on-fix]
16+
files: ^Lib/
17+
exclude: ^Lib/test/
1318
- id: ruff-check
1419
name: Run Ruff (lint) on Lib/test/
1520
args: [--exit-non-zero-on-fix]

Lib/.ruff.toml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
extend = "../.ruff.toml" # Inherit the project-wide settings
2+
3+
# Unlike Tools/, stdlib can use newer syntax than PYTHON_FOR_REGEN
4+
target-version = "py315"
5+
6+
[lint]
7+
select = [
8+
"F401", # Unused import
9+
]
10+
11+
[lint.per-file-ignores]
12+
"ctypes/__init__.py" = ["F401"] # Re-exports from _ctypes
13+
"ensurepip/__init__.py" = ["F401"] # `import zlib` availability check
14+
"idlelib/idle_test/htest.py" = ["F401"] # Import for Windows DPI side effect
15+
"idlelib/idle_test/test_iomenu.py" = ["F401"] # Imports checked for existence
16+
"importlib/_abc.py" = ["F401"] # Bootstrap-sensitive _bootstrap import
17+
"importlib/machinery.py" = ["F401"] # NamespacePath re-export
18+
"importlib/metadata/__init__.py" = ["F401"] # Synced from importlib_metadata
19+
"profiling/sampling/sample.py" = ["F401"] # Re-exports PROFILING_MODE_* constants
20+
"ssl.py" = ["F401"] # Re-exports from _ssl
21+
"warnings.py" = ["F401"] # Re-exports from _py_warnings

Lib/_pyrepl/completing_reader.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
# types
3333
Command = commands.Command
3434
if TYPE_CHECKING:
35-
from .types import CommandName, CompletionAction, Keymap, KeySpec
35+
from .types import CompletionAction, Keymap
3636

3737

3838
def prefix(wordlist: list[str], j: int = 0) -> str:

Lib/_pyrepl/reader.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
)
3939
from .layout import LayoutMap, LayoutResult, LayoutRow, WrappedRow, layout_content_lines
4040
from .render import RenderCell, RenderLine, RenderedScreen, ScreenOverlay
41-
from .utils import ANSI_ESCAPE_SEQUENCE, ColorSpan, THEME, StyleRef, wlen, gen_colors
41+
from .utils import ANSI_ESCAPE_SEQUENCE, ColorSpan, THEME, StyleRef, gen_colors
4242
from .trace import trace
4343

4444

Lib/_pyrepl/unix_console.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
from collections.abc import Callable
3535
from dataclasses import dataclass
3636
from fcntl import ioctl
37-
from typing import TYPE_CHECKING, cast, overload
37+
from typing import TYPE_CHECKING, overload
3838

3939
from . import terminfo
4040
from .console import Console, Event

Lib/idlelib/idle_test/template.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
"Test , coverage %."
22

3-
from idlelib import zzdummy
43
import unittest
54
from test.support import requires
65
from tkinter import Tk

Lib/idlelib/idle_test/test_help.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import unittest
55
from test.support import requires
66
requires('gui')
7-
from os.path import abspath, dirname, join
87
from tkinter import Tk
98

109

Lib/profiling/sampling/heatmap_collector.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,9 @@
55
import html
66
import importlib.resources
77
import json
8-
import locale
98
import math
109
import os
1110
import platform
12-
import site
1311
import sys
1412
from dataclasses import dataclass, field
1513
from pathlib import Path

Lib/profiling/sampling/live_collector/collector.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,6 @@
1818
THREAD_STATUS_UNKNOWN,
1919
THREAD_STATUS_GIL_REQUESTED,
2020
THREAD_STATUS_HAS_EXCEPTION,
21-
PROFILING_MODE_CPU,
22-
PROFILING_MODE_GIL,
23-
PROFILING_MODE_WALL,
2421
)
2522
from .constants import (
2623
MICROSECONDS_PER_SECOND,

Lib/profiling/sampling/live_collector/display.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
"""Display interface abstractions for the live profiling collector."""
22

3-
import contextlib
43
import curses
54
from abc import ABC, abstractmethod
65

0 commit comments

Comments
 (0)