Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Update mypy_test.py
  • Loading branch information
AlexWaygood authored Jan 11, 2023
commit db0924d49008ad6a98fc47af1cce2cd4ddb92875
8 changes: 8 additions & 0 deletions tests/mypy_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import tempfile
import time
from collections import defaultdict
from collections.abc import Sequence
from dataclasses import dataclass
from itertools import product
from pathlib import Path
Expand Down Expand Up @@ -77,6 +78,13 @@ def valid_path(cmd_arg: str) -> Path:
parser = argparse.ArgumentParser(
description="Typecheck typeshed's stubs with mypy. Patterns are unanchored regexps on the full path."
)
if sys.version_info < (3, 8):
class ExtendAction(argparse.Action):
def __call__(self, parser: argparse.ArgumentParser, namespace: argparse.Namespace, values: Sequence[str], option_string: object = None) -> None:
items = getattr(namespace, self.dest) or []
items.extend(values)
setattr(namespace, self.dest, items)
parser.register('action', 'extend', ExtendAction)
parser.add_argument(
"filter",
type=valid_path,
Expand Down