From 35b16795d11cb50768ffad5fe8e61bdebde9b66a Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Mon, 17 Jun 2024 21:58:56 +0200 Subject: [PATCH] gh-120417: Remove unused imports in cases_generator (#120622) --- Tools/cases_generator/analyzer.py | 2 +- Tools/cases_generator/generators_common.py | 4 +--- Tools/cases_generator/opcode_id_generator.py | 3 --- Tools/cases_generator/opcode_metadata_generator.py | 4 ---- Tools/cases_generator/optimizer_generator.py | 3 +-- Tools/cases_generator/parser.py | 2 +- Tools/cases_generator/py_metadata_generator.py | 1 - Tools/cases_generator/target_generator.py | 1 - Tools/cases_generator/tier1_generator.py | 8 ++------ Tools/cases_generator/tier2_generator.py | 6 +----- Tools/cases_generator/uop_id_generator.py | 3 --- 11 files changed, 7 insertions(+), 30 deletions(-) diff --git a/Tools/cases_generator/analyzer.py b/Tools/cases_generator/analyzer.py index e44bebd8f3c..96e2fd57c74 100644 --- a/Tools/cases_generator/analyzer.py +++ b/Tools/cases_generator/analyzer.py @@ -1,4 +1,4 @@ -from dataclasses import dataclass, field +from dataclasses import dataclass import lexer import parser import re diff --git a/Tools/cases_generator/generators_common.py b/Tools/cases_generator/generators_common.py index cc9eb8a0e90..efbfc94b415 100644 --- a/Tools/cases_generator/generators_common.py +++ b/Tools/cases_generator/generators_common.py @@ -4,14 +4,12 @@ from typing import TextIO from analyzer import ( Instruction, Uop, - analyze_files, Properties, - Skip, ) from cwriter import CWriter from typing import Callable, Mapping, TextIO, Iterator from lexer import Token -from stack import StackOffset, Stack +from stack import Stack ROOT = Path(__file__).parent.parent.parent diff --git a/Tools/cases_generator/opcode_id_generator.py b/Tools/cases_generator/opcode_id_generator.py index 5a3009a5c04..7932379b02d 100644 --- a/Tools/cases_generator/opcode_id_generator.py +++ b/Tools/cases_generator/opcode_id_generator.py @@ -4,12 +4,9 @@ Writes the IDs to opcode_ids.h by default. """ import argparse -import os.path -import sys from analyzer import ( Analysis, - Instruction, analyze_files, ) from generators_common import ( diff --git a/Tools/cases_generator/opcode_metadata_generator.py b/Tools/cases_generator/opcode_metadata_generator.py index 2632eb89ce8..0f5790dc4af 100644 --- a/Tools/cases_generator/opcode_metadata_generator.py +++ b/Tools/cases_generator/opcode_metadata_generator.py @@ -4,15 +4,12 @@ Writes the metadata to pycore_opcode_metadata.h by default. """ import argparse -import os.path -import sys from analyzer import ( Analysis, Instruction, PseudoInstruction, analyze_files, - Skip, Uop, ) from generators_common import ( @@ -20,7 +17,6 @@ from generators_common import ( ROOT, write_header, cflags, - StackOffset, ) from cwriter import CWriter from typing import TextIO diff --git a/Tools/cases_generator/optimizer_generator.py b/Tools/cases_generator/optimizer_generator.py index d5592672a55..fb3e577de73 100644 --- a/Tools/cases_generator/optimizer_generator.py +++ b/Tools/cases_generator/optimizer_generator.py @@ -18,13 +18,12 @@ from generators_common import ( ROOT, write_header, emit_tokens, - emit_to, replace_sync_sp, ) from cwriter import CWriter from typing import TextIO, Iterator from lexer import Token -from stack import Stack, SizeMismatch, UNUSED +from stack import Stack, SizeMismatch DEFAULT_OUTPUT = ROOT / "Python/optimizer_cases.c.h" DEFAULT_ABSTRACT_INPUT = (ROOT / "Python/optimizer_bytecodes.c").absolute().as_posix() diff --git a/Tools/cases_generator/parser.py b/Tools/cases_generator/parser.py index 2b77d14d211..db672ad5501 100644 --- a/Tools/cases_generator/parser.py +++ b/Tools/cases_generator/parser.py @@ -1,4 +1,4 @@ -from parsing import ( +from parsing import ( # noqa: F401 InstDef, Macro, Pseudo, diff --git a/Tools/cases_generator/py_metadata_generator.py b/Tools/cases_generator/py_metadata_generator.py index 0dbcd599f9d..3f7ffbc5523 100644 --- a/Tools/cases_generator/py_metadata_generator.py +++ b/Tools/cases_generator/py_metadata_generator.py @@ -12,7 +12,6 @@ from analyzer import ( from generators_common import ( DEFAULT_INPUT, ROOT, - root_relative_path, write_header, ) from cwriter import CWriter diff --git a/Tools/cases_generator/target_generator.py b/Tools/cases_generator/target_generator.py index 44a699c92bb..7f610bff629 100644 --- a/Tools/cases_generator/target_generator.py +++ b/Tools/cases_generator/target_generator.py @@ -14,7 +14,6 @@ from generators_common import ( ROOT, ) from cwriter import CWriter -from typing import TextIO DEFAULT_OUTPUT = ROOT / "Python/opcode_targets.h" diff --git a/Tools/cases_generator/tier1_generator.py b/Tools/cases_generator/tier1_generator.py index fb2ab931b1c..5df4413e833 100644 --- a/Tools/cases_generator/tier1_generator.py +++ b/Tools/cases_generator/tier1_generator.py @@ -4,8 +4,6 @@ Writes the cases to generated_cases.c.h, which is #included in ceval.c. """ import argparse -import os.path -import sys from analyzer import ( Analysis, @@ -14,7 +12,6 @@ from analyzer import ( Part, analyze_files, Skip, - StackItem, analysis_error, ) from generators_common import ( @@ -24,9 +21,8 @@ from generators_common import ( emit_tokens, ) from cwriter import CWriter -from typing import TextIO, Iterator -from lexer import Token -from stack import StackOffset, Stack, SizeMismatch +from typing import TextIO +from stack import Stack, SizeMismatch DEFAULT_OUTPUT = ROOT / "Python/generated_cases.c.h" diff --git a/Tools/cases_generator/tier2_generator.py b/Tools/cases_generator/tier2_generator.py index 944d134f12a..a091870489f 100644 --- a/Tools/cases_generator/tier2_generator.py +++ b/Tools/cases_generator/tier2_generator.py @@ -4,16 +4,12 @@ Writes the cases to executor_cases.c.h, which is #included in ceval.c. """ import argparse -import os.path -import sys from analyzer import ( Analysis, Instruction, Uop, - Part, analyze_files, - Skip, StackItem, analysis_error, ) @@ -28,7 +24,7 @@ from generators_common import ( from cwriter import CWriter from typing import TextIO, Iterator from lexer import Token -from stack import StackOffset, Stack, SizeMismatch +from stack import Stack, SizeMismatch DEFAULT_OUTPUT = ROOT / "Python/executor_cases.c.h" diff --git a/Tools/cases_generator/uop_id_generator.py b/Tools/cases_generator/uop_id_generator.py index eb5e3f4a324..aae89faaa92 100644 --- a/Tools/cases_generator/uop_id_generator.py +++ b/Tools/cases_generator/uop_id_generator.py @@ -4,12 +4,9 @@ Writes the IDs to pycore_uop_ids.h by default. """ import argparse -import os.path -import sys from analyzer import ( Analysis, - Instruction, analyze_files, ) from generators_common import (