Skip to content

Commit

Permalink
run-mypy: Remove options that duplicate the mypy configuration.
Browse files Browse the repository at this point in the history
Signed-off-by: Anders Kaseorg <anders@zulip.com>
  • Loading branch information
andersk committed Oct 27, 2023
1 parent 0d68c1f commit 61fe2ec
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 68 deletions.
7 changes: 7 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ src_paths = ["."]
profile = "black"

[tool.mypy]
scripts_are_modules = true
strict = true
enable_error_code = [
"redundant-self",
Expand All @@ -16,6 +17,12 @@ enable_error_code = [
]
warn_unreachable = true

[[tool.mypy.overrides]]
module = [
"setuptools.*",
]
ignore_missing_imports = true

[tool.ruff]
# See https://github.com/charliermarsh/ruff#rules for error code definitions.
select = [
Expand Down
69 changes: 1 addition & 68 deletions tools/run-mypy
Original file line number Diff line number Diff line change
Expand Up @@ -44,55 +44,6 @@ parser.add_argument(
find out which files fail mypy check.""",
)

parser.add_argument(
"--no-disallow-untyped-defs",
dest="disallow_untyped_defs",
action="store_false",
default=True,
help="""Don't throw errors when functions are not
annotated""",
)

parser.add_argument(
"--scripts-only",
dest="scripts_only",
action="store_true",
default=False,
help="""Only type check extensionless python scripts""",
)

parser.add_argument(
"--no-strict-optional",
dest="strict_optional",
action="store_false",
default=True,
help="""Don't use the --strict-optional flag with mypy""",
)

parser.add_argument(
"--warn-unused-ignores",
dest="warn_unused_ignores",
action="store_true",
default=False,
help="""Use the --warn-unused-ignores flag with mypy""",
)

parser.add_argument(
"--no-ignore-missing-imports",
dest="ignore_missing_imports",
action="store_false",
default=True,
help="""Don't use the
--ignore-missing-imports flag with mypy""",
)

parser.add_argument(
"--quick",
action="store_true",
default=False,
help="""Use the --quick flag with mypy""",
)

args = parser.parse_args()

files_dict = lister.list_files(
Expand All @@ -118,26 +69,8 @@ if not python_files and not pyi_files:

mypy_command = "mypy"

extra_args = [
"--check-untyped-defs",
"--follow-imports=silent",
"--scripts-are-modules",
"--disallow-any-generics",
"-i",
]
if args.disallow_untyped_defs:
extra_args.append("--disallow-untyped-defs")
if args.warn_unused_ignores:
extra_args.append("--warn-unused-ignores")
if args.strict_optional:
extra_args.append("--strict-optional")
if args.ignore_missing_imports:
extra_args.append("--ignore-missing-imports")
if args.quick:
extra_args.append("--quick")

# run mypy
status = subprocess.call([mypy_command, *extra_args, "--", *python_files])
status = subprocess.call([mypy_command, "--", *python_files])

if status != 0:
print("")
Expand Down

0 comments on commit 61fe2ec

Please sign in to comment.