Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add more docstrings and type hints #1641

Merged
merged 21 commits into from
Sep 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
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
2 changes: 1 addition & 1 deletion pyiron_base/cli/control.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
}


def main():
def main() -> None:
parser = argparse.ArgumentParser(prog="pyiron", description=__doc__)
parser.add_argument(
"-d", "--dirty", action="store_true", help="do not remove pyiron log files"
Expand Down
6 changes: 4 additions & 2 deletions pyiron_base/cli/cp.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,17 @@
Copy a pyiron project to a new location.
"""

from argparse import ArgumentParser, Namespace

from pyiron_base.project.generic import Project


def register(parser):
def register(parser: ArgumentParser) -> None:
parser.add_argument("src", help="source project")
parser.add_argument("dst", help="destination project")


def main(args):
def main(args: Namespace) -> None:
src = Project(args.src)
dst = Project(args.dst)
src.copy_to(dst)
6 changes: 4 additions & 2 deletions pyiron_base/cli/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
Install pyiron config and resources for the first time.
"""

from argparse import ArgumentParser, Namespace

from pyiron_base.state.install import install_pyiron

__author__ = "Marvin Poul"
Expand All @@ -19,7 +21,7 @@
__date__ = "Jun 26, 2020"


def register(parser):
def register(parser: ArgumentParser) -> None:
parser.add_argument(
"-c",
"--config",
Expand All @@ -46,7 +48,7 @@ def register(parser):
)


def main(args):
def main(args: Namespace) -> None:
install_pyiron(
config_file_name=args.config,
project_path=args.project,
Expand Down
4 changes: 2 additions & 2 deletions pyiron_base/cli/ls.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
"""


def register(parser):
def register(parser: argparse.ArgumentParser) -> None:
parser.add_argument(
"project", default=".", nargs="?", help="path to pyiron project"
)
Expand Down Expand Up @@ -123,7 +123,7 @@ def register(parser):
)


def main(args):
def main(args: argparse.Namespace) -> None:
if args.status:
if "status" not in args.columns:
args.columns = args.columns + ["status"]
Expand Down
6 changes: 4 additions & 2 deletions pyiron_base/cli/mv.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,17 @@
Move a pyiron project to a new location.
"""

from argparse import ArgumentParser, Namespace

from pyiron_base.project.generic import Project


def register(parser):
def register(parser: ArgumentParser) -> None:
parser.add_argument("src", help="source project")
parser.add_argument("dst", help="destination project")


def main(args):
def main(args: Namespace) -> None:
src = Project(args.src)
dst = Project(args.dst)
src.move_to(dst)
5 changes: 3 additions & 2 deletions pyiron_base/cli/reloadfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@
# Distributed under the terms of "New BSD License", see the LICENSE file.
import os
import shutil
from argparse import ArgumentParser, Namespace

from h5io_browser.base import _open_hdf

from pyiron_base import Project
from pyiron_base.state import state


def register(parser):
def register(parser: ArgumentParser) -> None:
parser.add_argument(
"-i",
"--input-path",
Expand All @@ -23,7 +24,7 @@ def register(parser):
)


def main(args):
def main(args: Namespace) -> None:
with _open_hdf(filename=args.input_path, mode="r") as f:
job_name = list(f.keys())[0]
project_path = os.path.join(os.path.abspath("."), job_name + ".h5")
Expand Down
5 changes: 3 additions & 2 deletions pyiron_base/cli/rm.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"""

import os
from argparse import ArgumentParser, Namespace

from pyiron_base.project.generic import Project

Expand All @@ -20,7 +21,7 @@
__date__ = "23 Jun, 2020"


def register(parser):
def register(parser: ArgumentParser):
parser.add_argument(
"project", default=".", nargs="?", help="path to pyiron project"
)
Expand All @@ -32,7 +33,7 @@ def register(parser):
)


def main(args):
def main(args: Namespace) -> None:
pr = Project(args.project)
if args.jobs_only:
pr.remove_jobs(recursive=args.recursive, silently=True)
Expand Down
6 changes: 4 additions & 2 deletions pyiron_base/cli/wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@
Run a job from hdf5.
"""

from argparse import ArgumentParser, Namespace

from pyiron_base.jobs.job.wrapper import job_wrapper_function


def register(parser):
def register(parser: ArgumentParser):
parser.add_argument(
"-d",
"--debug",
Expand All @@ -33,7 +35,7 @@ def register(parser):
)


def main(args):
def main(args: Namespace) -> None:
job_wrapper_function(
working_directory=args.project,
job_id=args.job_id,
Expand Down
Loading
Loading