Skip to content

Commit 44a97a8

Browse files
spoorccben-edna
authored andcommitted
Add SubparserActionType
1 parent 1c53415 commit 44a97a8

10 files changed

Lines changed: 17 additions & 21 deletions

File tree

dfetch/commands/check.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
import argparse
2323
import os
24-
from typing import Any, List # pylint: disable=unused-import
24+
from typing import List
2525

2626
import dfetch.commands.command
2727
import dfetch.manifest.manifest
@@ -46,7 +46,7 @@ class Check(dfetch.commands.command.Command):
4646
"""
4747

4848
@staticmethod
49-
def create_menu(subparsers: "argparse._SubParsersAction[Any]") -> None:
49+
def create_menu(subparsers: dfetch.commands.command.SubparserActionType) -> None:
5050
"""Add the parser menu for this action."""
5151
parser = dfetch.commands.command.Command.parser(subparsers, Check)
5252
parser.add_argument(

dfetch/commands/command.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44
from abc import ABC, abstractmethod
55
from typing import Any, Type, TypeVar, cast # pylint: disable=unused-import
66

7+
SubparserActionType = argparse._SubParsersAction[ # pyright: ignore[reportPrivateUsage]
8+
Any
9+
]
10+
711

812
class Command(ABC):
913
"""An abstract command that dfetch can perform.
@@ -20,7 +24,7 @@ class Command(ABC):
2024

2125
@staticmethod
2226
@abstractmethod
23-
def create_menu(subparsers: "argparse._SubParsersAction[Any]") -> None:
27+
def create_menu(subparsers: SubparserActionType) -> None:
2428
"""Add a sub-parser to the given parser.
2529
2630
Args:
@@ -42,7 +46,7 @@ def __call__(self, args: argparse.Namespace) -> None:
4246

4347
@staticmethod
4448
def parser(
45-
subparsers: "argparse._SubParsersAction[Any]",
49+
subparsers: SubparserActionType,
4650
command: Type["Command.CHILD_TYPE"],
4751
) -> "argparse.ArgumentParser":
4852
"""Generate the parser.

dfetch/commands/diff.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@
5252

5353
import argparse
5454
import os
55-
from typing import Any # pylint: disable=unused-import
5655
from typing import List
5756

5857
import dfetch.commands.command
@@ -79,7 +78,7 @@ class Diff(dfetch.commands.command.Command):
7978
"""
8079

8180
@staticmethod
82-
def create_menu(subparsers: "argparse._SubParsersAction[Any]") -> None:
81+
def create_menu(subparsers: dfetch.commands.command.SubparserActionType) -> None:
8382
"""Add the parser menu for this action."""
8483
parser = dfetch.commands.command.Command.parser(subparsers, Diff)
8584
parser.add_argument(

dfetch/commands/environment.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import argparse
44
import platform
5-
from typing import Any # pylint: disable=unused-import
65

76
import dfetch.commands.command
87
from dfetch.log import get_logger
@@ -18,7 +17,7 @@ class Environment(dfetch.commands.command.Command):
1817
"""
1918

2019
@staticmethod
21-
def create_menu(subparsers: "argparse._SubParsersAction[Any]") -> None:
20+
def create_menu(subparsers: dfetch.commands.command.SubparserActionType) -> None:
2221
"""Add the parser menu for this action."""
2322
dfetch.commands.command.Command.parser(subparsers, Environment)
2423

dfetch/commands/freeze.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@
4141
import argparse
4242
import os
4343
import shutil
44-
from typing import Any # pylint: disable=unused-import
4544
from typing import List
4645

4746
import dfetch.commands.command
@@ -63,7 +62,7 @@ class Freeze(dfetch.commands.command.Command):
6362
"""
6463

6564
@staticmethod
66-
def create_menu(subparsers: "argparse._SubParsersAction[Any]") -> None:
65+
def create_menu(subparsers: dfetch.commands.command.SubparserActionType) -> None:
6766
"""Add the parser menu for this action."""
6867
dfetch.commands.command.Command.parser(subparsers, Freeze)
6968

dfetch/commands/import_.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,6 @@
8484
import os
8585
import re
8686
from itertools import combinations
87-
from typing import Any # pylint: disable=unused-import
8887
from typing import List, Sequence, Set, Tuple
8988

9089
import dfetch.commands.command
@@ -107,7 +106,7 @@ class Import(dfetch.commands.command.Command):
107106
"""
108107

109108
@staticmethod
110-
def create_menu(subparsers: "argparse._SubParsersAction[Any]") -> None:
109+
def create_menu(subparsers: dfetch.commands.command.SubparserActionType) -> None:
111110
"""Add the parser menu for this action."""
112111
dfetch.commands.command.Command.parser(subparsers, Import)
113112

@@ -265,7 +264,7 @@ def _determine_best_remotes(projects_urls: Set[str]) -> Tuple[str, ...]:
265264
potential_remotes = potential_remotes - useless_potential
266265

267266
# For each permutation of any length, calculate the solution score
268-
solutions = []
267+
solutions: List[Tuple[int, Tuple[str, ...]]] = []
269268
for i in range(min(len(potential_remotes), max_remotes)):
270269
for solution in combinations(potential_remotes, i):
271270
score = _calculate_solution_score(solution, projects_urls)

dfetch/commands/init.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import argparse
77
import os
88
import shutil
9-
from typing import Any # pylint: disable=unused-import
109

1110
import dfetch.commands.command
1211
from dfetch import DEFAULT_MANIFEST_NAME
@@ -23,7 +22,7 @@ class Init(dfetch.commands.command.Command):
2322
"""
2423

2524
@staticmethod
26-
def create_menu(subparsers: "argparse._SubParsersAction[Any]") -> None:
25+
def create_menu(subparsers: dfetch.commands.command.SubparserActionType) -> None:
2726
"""Add the parser menu for this action."""
2827
dfetch.commands.command.Command.parser(subparsers, Init)
2928

dfetch/commands/report.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import argparse
77
import glob
88
import os
9-
from typing import Any # pylint: disable=unused-import
109

1110
import infer_license
1211

@@ -29,7 +28,7 @@ class Report(dfetch.commands.command.Command):
2928
"""
3029

3130
@staticmethod
32-
def create_menu(subparsers: "argparse._SubParsersAction[Any]") -> None:
31+
def create_menu(subparsers: dfetch.commands.command.SubparserActionType) -> None:
3332
"""Add the parser menu for this action."""
3433
parser = dfetch.commands.command.Command.parser(subparsers, Report)
3534

dfetch/commands/update.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
import argparse
2323
import os
2424
from pathlib import Path
25-
from typing import Any # pylint: disable=unused-import
2625
from typing import List
2726

2827
import dfetch.commands.command
@@ -45,7 +44,7 @@ class Update(dfetch.commands.command.Command):
4544
"""
4645

4746
@staticmethod
48-
def create_menu(subparsers: "argparse._SubParsersAction[Any]") -> None:
47+
def create_menu(subparsers: dfetch.commands.command.SubparserActionType) -> None:
4948
"""Add the menu for the update action."""
5049
parser = dfetch.commands.command.Command.parser(subparsers, Update)
5150
parser.add_argument(

dfetch/commands/validate.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88

99
import argparse
1010
import os
11-
from typing import Any # pylint: disable=unused-import
1211

1312
import dfetch.commands.command
1413
from dfetch.log import get_logger
@@ -26,7 +25,7 @@ class Validate(dfetch.commands.command.Command):
2625
"""
2726

2827
@staticmethod
29-
def create_menu(subparsers: "argparse._SubParsersAction[Any]") -> None:
28+
def create_menu(subparsers: dfetch.commands.command.SubparserActionType) -> None:
3029
"""Add the parser menu for this action."""
3130
dfetch.commands.command.Command.parser(subparsers, Validate)
3231

0 commit comments

Comments
 (0)