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
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ jobs:
python-version: ${{ matrix.python-version }}
- run: pip install -e ".[dev]"
- run: pytest
- run: mypy fixit
1 change: 1 addition & 0 deletions README.hi.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

## 🎯 यह क्या है?

Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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?

Expand Down
22 changes: 12 additions & 10 deletions fixit/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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")
Expand All @@ -33,44 +35,44 @@ def run_wc(args):
)


def run_convert(args):
def run_convert(args: argparse.Namespace) -> None:
try:
result = CONVERSIONS[args.kind](args.value)
print(result)
except KeyError:
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))


Expand Down Expand Up @@ -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:
Expand Down
8 changes: 7 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
Loading