From cc28a1fc4899c54878660db2a0498482b73f59e9 Mon Sep 17 00:00:00 2001 From: G-type <162748908+gtref@users.noreply.github.com> Date: Sat, 24 Oct 2026 22:28:17 +1300 Subject: [PATCH 1/2] Add mypy hints to fixit/cli.py. Signed-off-by: G-type <162748908+gtref@users.noreply.github.com> --- .github/workflows/ci.yml | 1 + fixit/cli.py | 22 ++++++++++++---------- pyproject.toml | 8 +++++++- 3 files changed, 20 insertions(+), 11 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9b65664..387e02e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,3 +18,4 @@ jobs: python-version: ${{ matrix.python-version }} - run: pip install -e ".[dev]" - run: pytest + - run: mypy fixit diff --git a/fixit/cli.py b/fixit/cli.py index 1e82f44..52d4ffb 100644 --- a/fixit/cli.py +++ b/fixit/cli.py @@ -3,7 +3,9 @@ import argparse import sys import uuid +from collections.abc import Sequence from pathlib import Path +from typing import Optional from fixit import __version__, convert, jsonfmt, password, textutils, wordcount @@ -15,7 +17,7 @@ } -def run_wc(args): +def run_wc(args: argparse.Namespace) -> None: if args.file is not None: try: text = args.file.read_text(encoding="utf-8") @@ -33,7 +35,7 @@ def run_wc(args): ) -def run_convert(args): +def run_convert(args: argparse.Namespace) -> None: try: result = CONVERSIONS[args.kind](args.value) print(result) @@ -41,36 +43,36 @@ def run_convert(args): raise ValueError(f"Error: unknown conversion '{args.kind}'") -def run_password(args): +def run_password(args: argparse.Namespace) -> None: print(password.generate(args.length, use_symbols=args.symbols)) -def run_uuid(args): +def run_uuid(args: argparse.Namespace) -> None: for _ in range(args.count): print(uuid.uuid4()) -def run_json(args): +def run_json(args: argparse.Namespace) -> None: try: print(jsonfmt.format_json(args.raw)) except ValueError as e: raise ValueError(f"Error: invalid JSON - {e}") -def run_palindrome(args): +def run_palindrome(args: argparse.Namespace) -> None: print(textutils.is_palindrome(args.text)) -def run_reverse(args): +def run_reverse(args: argparse.Namespace) -> None: print(textutils.reverse_words(args.text)) -def run_top_words(args): +def run_top_words(args: argparse.Namespace) -> None: for word, count in wordcount.top_words(args.text, args.n): print(f"{word}: {count}") -def run_slugify(args): +def run_slugify(args: argparse.Namespace) -> None: print(textutils.slugify(args.text)) @@ -137,7 +139,7 @@ def build_parser() -> argparse.ArgumentParser: return parser -def main(argv=None) -> int: +def main(argv: Optional[Sequence[str]] = None) -> int: """Run a fixit command and return its exit status. Example: diff --git a/pyproject.toml b/pyproject.toml index 7f5cd8f..3b112b3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -11,7 +11,7 @@ requires-python = ">=3.8" license = { text = "MIT" } [project.optional-dependencies] -dev = ["pytest", "ruff>=0.12.0"] +dev = ["pytest", "ruff>=0.12.0", "mypy>=1.0,<2"] [project.scripts] fixit = "fixit.cli:main" @@ -23,5 +23,11 @@ packages = ["fixit"] line-length = 88 target-version = "py39" +[tool.ruff.lint.per-file-ignores] +"fixit/cli.py" = ["FA100"] + [tool.pytest.ini_options] testpaths = ["tests"] + +[tool.mypy] +python_version = "3.9" From 5b7fc889da501b44373d794d14515612baf38b82 Mon Sep 17 00:00:00 2001 From: G-type <162748908+gtref@users.noreply.github.com> Date: Sat, 24 Oct 2026 22:33:12 +1300 Subject: [PATCH 2/2] Add badge to readme.md outlining CI.yml workflow status. Signed-off-by: G-type <162748908+gtref@users.noreply.github.com> --- README.hi.md | 1 + README.md | 1 + 2 files changed, 2 insertions(+) diff --git a/README.hi.md b/README.hi.md index e05052b..6fcc553 100644 --- a/README.hi.md +++ b/README.hi.md @@ -7,6 +7,7 @@ ![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen) ![good first issues](https://img.shields.io/badge/good%20first%20issues-30%2B-orange) [![Ruff](https://github.com/codepiyusss/open_source_issue_contribution/actions/workflows/ruff.yml/badge.svg)](https://github.com/codepiyusss/open_source_issue_contribution/actions/workflows/ruff.yml) +[![CI](https://github.com/codepiyusss/open_source_issue_contribution/actions/workflows/ci.yml/badge.svg)](https://github.com/codepiyusss/open_source_issue_contribution/actions/workflows/ci.yml) ## 🎯 यह क्या है? diff --git a/README.md b/README.md index 244f03b..dc6436a 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,7 @@ ![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen) ![good first issues](https://img.shields.io/badge/good%20first%20issues-30%2B-orange) [![Ruff](https://github.com/codepiyusss/open_source_issue_contribution/actions/workflows/ruff.yml/badge.svg)](https://github.com/codepiyusss/open_source_issue_contribution/actions/workflows/ruff.yml) +[![CI](https://github.com/codepiyusss/open_source_issue_contribution/actions/workflows/ci.yml/badge.svg)](https://github.com/codepiyusss/open_source_issue_contribution/actions/workflows/ci.yml) ## 🎯 What is this?