Skip to content

Commit

Permalink
Add mypy command
Browse files Browse the repository at this point in the history
  • Loading branch information
saroad2 committed May 13, 2020
1 parent c1aadb0 commit 5a4e9a7
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 12 deletions.
1 change: 1 addition & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ install_requires =
isort >= 4.3.21
pylint >= 2.5.2
pydocstyle >= 5.0.2
mypy >= 0.770

[options.packages.find]
where = src
Expand Down
6 changes: 3 additions & 3 deletions src/eddington_static/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,13 @@
)


def print_commands():
def print_commands() -> None:
"""Print all supported commands."""
for command in COMMANDS:
print(command)


def print_title(title):
def print_title(title: str) -> None:
"""
Print a title with a title line under it.
Expand All @@ -54,7 +54,7 @@ def print_title(title):
print("=" * len(title))


def main():
def main() -> None:
"""A main function of Eddington-Static."""
args = parser.parse_args()
if args.commands_list:
Expand Down
24 changes: 15 additions & 9 deletions src/eddington_static/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,18 @@ class Command:

name: str
help: str
args: List[str] = field(default=None)
test_args: List[str] = field(default=None)
args: Union[List[str], None] = field(default=None)
test_args: Union[List[str], None] = field(default=None)
check_arg: Union[str, None] = field(default=None)

def execute( # pylint: disable=too-many-arguments
self,
input_paths,
is_format=False,
is_silent=False,
is_verbose=False,
is_test=False,
):
input_paths: List[str],
is_format: bool = False,
is_silent: bool = False,
is_verbose: bool = False,
is_test: bool = False,
) -> int:
"""
Execute the command.
Expand All @@ -57,7 +57,7 @@ def execute( # pylint: disable=too-many-arguments
args, env=os.environ, check=False, capture_output=is_silent,
).returncode

def __repr__(self):
def __repr__(self) -> str:
"""
Create a representation string for the command.
Expand All @@ -83,6 +83,11 @@ def __repr__(self):
check_arg="--check-only",
help="A tool for sorting and cleaning python imports",
)
MYPY = Command(
name="mypy",
args=["--strict", "--allow-untyped-calls"],
help="Validate types using mypy",
)
PYLINT = Command(
name="pylint",
args=["--disable=C0330,E0401"],
Expand All @@ -100,6 +105,7 @@ def __repr__(self):
BLACK,
FLAKE8,
ISORT,
MYPY,
PYLINT,
PYDOCSTYLE,
]

0 comments on commit 5a4e9a7

Please sign in to comment.