Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
19 changes: 19 additions & 0 deletions .githooks/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/usr/bin/env bash
set -euo pipefail

REPO_ROOT="$(git rev-parse --show-toplevel)"
PYTHON_BIN="$REPO_ROOT/.venv/bin/python"
CONFIG_PATH="$REPO_ROOT/.pre-commit-config.yaml"
HOOK_DIR="$REPO_ROOT/.githooks"

if [[ ! -x "$PYTHON_BIN" ]]; then
printf "Missing interpreter: %s\n" "$PYTHON_BIN" >&2
printf "Run: ./scripts/bootstrap_dev.sh\n" >&2
exit 1
fi

exec "$PYTHON_BIN" -m pre_commit hook-impl \
--config="$CONFIG_PATH" \
--hook-type=pre-commit \
--hook-dir "$HOOK_DIR" \
-- "$@"
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -161,4 +161,4 @@ cython_debug/
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/
#.idea/
8 changes: 7 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# To install the git pre-commit hook run:
# pre-commit install
# ./scripts/bootstrap_dev.sh
# To update the pre-commit hooks run:
# pre-commit install-hooks
repos:
Expand All @@ -15,3 +15,9 @@ repos:
- id: ruff
args: ["--fix"]
- id: ruff-format
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.15.0
hooks:
- id: mypy
args: ["--config-file=pyproject.toml"]
pass_filenames: false
8 changes: 8 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"python.defaultInterpreterPath": "${workspaceFolder}/.venv/bin/python",
"python.testing.pytestArgs": [
"tests"
],
"python.testing.unittestEnabled": false,
"python.testing.pytestEnabled": true
}
34 changes: 16 additions & 18 deletions ModelExplorer/__main__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# ModelExplorer/__main__.py
"""CLI entrypoint for launching the SasModels Explorer GUI."""

from __future__ import annotations

import argparse
import sys

from PyQt6.QtWidgets import QApplication
Expand All @@ -8,16 +11,8 @@
from ModelExplorer.utils.configure_logging import configure_logging


def setup_logging():
"""Configure basic console logging for the CLI entrypoint."""
import logging

logging.basicConfig(level=logging.INFO)


def setup_args(args=None):
def setup_args(args: list[str] | None = None) -> argparse.Namespace:
"""Parse CLI arguments for model selection and logging options."""
import argparse

parser = argparse.ArgumentParser(description="SasModels Explorer")
parser.add_argument("model", nargs="?", default="sphere@hardsphere", help="Model name to display")
Expand All @@ -37,23 +32,26 @@ def setup_args(args=None):
"-l",
"--logging",
action="store_true",
help="Write log out to a timestamped file.",
help="Write log output to a timestamped file.",
)
args = parser.parse_args(args)
return parser.parse_args(args)

return args


def main():
def main() -> None:
"""Launch the Qt application."""

argv = sys.argv
app = QApplication(argv)
args = setup_args(argv[1:])
configure_logging(args.verbose, args.very_verbose, log_to_file=args.logging, log_file_prepend="SasModelsExplorer_")

configure_logging(
args.verbose,
args.very_verbose,
log_to_file=args.logging,
log_file_prepend="SasModelsExplorer_",
)
window = SasModelApp(args.model)
window.show()
sys.exit(app.exec())
raise SystemExit(app.exec())


if __name__ == "__main__":
Expand Down
Loading