From c95e691c904bb5ebd91825efa81b93cb9e354a85 Mon Sep 17 00:00:00 2001 From: Anthony Shaw Date: Mon, 4 May 2020 12:03:05 +1000 Subject: [PATCH] Clean up unused imports for the peg generator module (GH-19891) --- Tools/peg_generator/pegen/build.py | 3 +-- Tools/peg_generator/pegen/c_generator.py | 2 +- Tools/peg_generator/pegen/first_sets.py | 3 +-- Tools/peg_generator/pegen/grammar.py | 3 --- Tools/peg_generator/pegen/grammar_visualizer.py | 2 +- Tools/peg_generator/scripts/ast_timings.py | 2 -- Tools/peg_generator/scripts/benchmark.py | 1 - Tools/peg_generator/scripts/find_max_nesting.py | 4 ---- Tools/peg_generator/scripts/test_parse_directory.py | 1 - 9 files changed, 4 insertions(+), 17 deletions(-) diff --git a/Tools/peg_generator/pegen/build.py b/Tools/peg_generator/pegen/build.py index 8f9348ddf24..931ffc78752 100644 --- a/Tools/peg_generator/pegen/build.py +++ b/Tools/peg_generator/pegen/build.py @@ -1,12 +1,11 @@ import pathlib import shutil import tokenize -import sys import sysconfig import tempfile import itertools -from typing import Optional, Tuple, List, IO, Iterator, Set, Dict +from typing import Optional, Tuple, List, IO, Set, Dict from pegen.c_generator import CParserGenerator from pegen.grammar import Grammar diff --git a/Tools/peg_generator/pegen/c_generator.py b/Tools/peg_generator/pegen/c_generator.py index c9c67067d46..40004e78752 100644 --- a/Tools/peg_generator/pegen/c_generator.py +++ b/Tools/peg_generator/pegen/c_generator.py @@ -1,7 +1,7 @@ import ast from dataclasses import dataclass, field import re -from typing import IO, Any, Dict, List, Optional, Set, Text, Tuple +from typing import Any, Dict, IO, Optional, List, Text, Tuple, Set from enum import Enum from pegen import grammar diff --git a/Tools/peg_generator/pegen/first_sets.py b/Tools/peg_generator/pegen/first_sets.py index da30eba99ce..71be5a2e7cb 100755 --- a/Tools/peg_generator/pegen/first_sets.py +++ b/Tools/peg_generator/pegen/first_sets.py @@ -1,10 +1,9 @@ #!/usr/bin/env python3.8 import argparse -import collections import pprint import sys -from typing import Optional, Set, Dict +from typing import Set, Dict from pegen.build import build_parser from pegen.grammar import ( diff --git a/Tools/peg_generator/pegen/grammar.py b/Tools/peg_generator/pegen/grammar.py index 67039d5a032..78edf412ea6 100644 --- a/Tools/peg_generator/pegen/grammar.py +++ b/Tools/peg_generator/pegen/grammar.py @@ -4,7 +4,6 @@ from abc import abstractmethod from typing import ( AbstractSet, Any, - Callable, Dict, Iterable, Iterator, @@ -13,11 +12,9 @@ from typing import ( Set, Tuple, TYPE_CHECKING, - TypeVar, Union, ) -from pegen.parser import memoize, Parser if TYPE_CHECKING: from pegen.parser_generator import ParserGenerator diff --git a/Tools/peg_generator/pegen/grammar_visualizer.py b/Tools/peg_generator/pegen/grammar_visualizer.py index b1d51d2cdb2..7362ec5fa0f 100644 --- a/Tools/peg_generator/pegen/grammar_visualizer.py +++ b/Tools/peg_generator/pegen/grammar_visualizer.py @@ -1,7 +1,7 @@ import argparse import sys -from typing import Any, Iterator, Iterable, Callable +from typing import Any, Iterator, Callable from pegen.build import build_parser from pegen.grammar import Grammar, Rule diff --git a/Tools/peg_generator/scripts/ast_timings.py b/Tools/peg_generator/scripts/ast_timings.py index 7ebd46fdac6..ca252208f28 100644 --- a/Tools/peg_generator/scripts/ast_timings.py +++ b/Tools/peg_generator/scripts/ast_timings.py @@ -1,8 +1,6 @@ import ast import sys import time -import token -import tokenize from pegen.testutil import print_memstats diff --git a/Tools/peg_generator/scripts/benchmark.py b/Tools/peg_generator/scripts/benchmark.py index 0e9d5bd1048..d39ac3dca79 100644 --- a/Tools/peg_generator/scripts/benchmark.py +++ b/Tools/peg_generator/scripts/benchmark.py @@ -4,7 +4,6 @@ import argparse import ast import sys import os -import resource from time import time import memory_profiler diff --git a/Tools/peg_generator/scripts/find_max_nesting.py b/Tools/peg_generator/scripts/find_max_nesting.py index a2c41a82134..f2fdd00bfb7 100755 --- a/Tools/peg_generator/scripts/find_max_nesting.py +++ b/Tools/peg_generator/scripts/find_max_nesting.py @@ -13,11 +13,7 @@ INITIAL_NESTING_DEPTH, or NESTED_INCR_AMT variables. Usage: python -m scripts.find_max_nesting """ -import os import sys -from tempfile import TemporaryDirectory -from pathlib import Path -from typing import Any from _peg_parser import parse_string diff --git a/Tools/peg_generator/scripts/test_parse_directory.py b/Tools/peg_generator/scripts/test_parse_directory.py index a6078ef5640..aef9c74b528 100755 --- a/Tools/peg_generator/scripts/test_parse_directory.py +++ b/Tools/peg_generator/scripts/test_parse_directory.py @@ -4,7 +4,6 @@ import argparse import ast import os import sys -import tempfile import time import traceback from glob import glob