Skip to content

Commit

Permalink
fixed all base errors to get the commit working
Browse files Browse the repository at this point in the history
  • Loading branch information
smorin committed Jan 23, 2025
1 parent 4c76166 commit d9d6543
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 22 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ uvx black py_launch_blueprint/
uvx isort py_launch_blueprint/

# Run type checker
uvx mypy py_launch_blueprint/
uvx --with-editable . mypy py_launch_blueprint/

# Run linter
uvx ruff check py_launch_blueprint/
Expand Down
35 changes: 18 additions & 17 deletions py_launch_blueprint/projects.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@
A command-line interface for searching and selecting Py projects,
with support for fuzzy matching and various output formats.
"""
# TODO: remove mypy: ignore-errors and fix all type errors
# mypy: ignore-errors

import json
import os
import sys
from dataclasses import dataclass
from pathlib import Path
from typing import Any, Dict, List, Optional
from typing import Any

import click
import pyperclip
Expand All @@ -21,7 +23,6 @@
from rich.console import Console
from rich.progress import Progress
from rich.table import Table
from thefuzz import fuzz, process

# Initialize Rich console for pretty output
console = Console()
Expand All @@ -46,10 +47,10 @@ class ConfigError(Exception):
class Config:
"""Configuration container."""

token: Optional[str] = None
token: str | None = None

@classmethod
def from_env(cls, env_path: Optional[str] = None) -> "Config":
def from_env(cls, env_path: str | None = None) -> "Config":
"""
Create Config from environment variables or .env file.
Expand Down Expand Up @@ -94,7 +95,7 @@ def get_config_path() -> Path:
return base_path / ".config" / "py-cli"


def get_config(config_path: Optional[str] = None) -> Config:
def get_config(config_path: str | None = None) -> Config:
"""
Get configuration from various sources.
Expand Down Expand Up @@ -145,7 +146,7 @@ def __init__(self, token: str):
}
)

def _request(self, method: str, path: str, **kwargs) -> Dict[str, Any]:
def _request(self, method: str, path: str, **kwargs) -> dict[str, Any]:
"""
Make a request to the Py API.
Expand Down Expand Up @@ -174,9 +175,9 @@ def _request(self, method: str, path: str, **kwargs) -> Dict[str, Any]:
error_msg = str(e)
else:
error_msg = str(e)
raise PyError(f"API request failed: {error_msg}")
raise PyError(f"API request failed: {error_msg}") from e

def get_workspaces(self) -> List[Dict[str, Any]]:
def get_workspaces(self) -> list[dict[str, Any]]:
"""
Get all accessible workspaces.
Expand All @@ -186,8 +187,8 @@ def get_workspaces(self) -> List[Dict[str, Any]]:
return self._request("GET", "/workspaces")

def get_projects(
self, workspace_name: Optional[str] = None, limit: int = 200
) -> List[Dict[str, Any]]:
self, workspace_name: str | None = None, limit: int = 200
) -> list[dict[str, Any]]:
"""
Get projects, optionally filtered by workspace.
Expand Down Expand Up @@ -219,7 +220,7 @@ def get_projects(


# CLI Functions
def setup_config(config_path: Optional[str] = None) -> Config:
def setup_config(config_path: str | None = None) -> Config:
"""
Set up configuration from various sources.
Expand All @@ -241,7 +242,7 @@ def setup_config(config_path: Optional[str] = None) -> Config:
sys.exit(1)


def format_output(projects: List[Dict[str, Any]], format: str) -> str:
def format_output(projects: list[dict[str, Any]], format: str) -> str:
"""
Format projects list according to specified format.
Expand All @@ -262,7 +263,7 @@ def format_output(projects: List[Dict[str, Any]], format: str) -> str:
return "\n".join(p["id"] for p in projects)


def display_projects(projects: List[Dict[str, Any]], verbose: bool = False) -> None:
def display_projects(projects: list[dict[str, Any]], verbose: bool = False) -> None:
"""
Display projects in a rich table format.
Expand Down Expand Up @@ -302,13 +303,13 @@ def display_projects(projects: List[Dict[str, Any]], verbose: bool = False) -> N
@click.option("--verbose", is_flag=True, help="Enable verbose output")
@click.version_option(version="0.1.0")
def main(
token: Optional[str],
config: Optional[str],
workspace: Optional[str],
token: str | None,
config: str | None,
workspace: str | None,
limit: int,
format: str,
copy: bool,
output: Optional[str],
output: str | None,
no_color: bool,
verbose: bool,
) -> None:
Expand Down
10 changes: 6 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ dev = [
"mypy>=1.0.0",
"ruff>=0.1.0",
"pre-commit>=4.1.0",
"types-requests",
"types-Pygments",
]

[project.scripts]
Expand All @@ -51,7 +53,7 @@ target-version = "py310"

# Line length
line-length = 88 # Match Black's default
select = [
lint.select = [
"E", # pycodestyle errors
"F", # pyflakes
"I", # isort
Expand All @@ -66,13 +68,13 @@ select = [
]

# Ignore specific rules
ignore = [
lint.ignore = [
# "E501", # line length violations
]

# Allow autofix behavior for specific rules
fix = true
unfixable = [] # Rules that should not be fixed automatically
lint.unfixable = [] # Rules that should not be fixed automatically

# Exclude files/folders
exclude = [
Expand All @@ -84,7 +86,7 @@ exclude = [
]

# Per-file-ignores
[tool.ruff.per-file-ignores]
[tool.ruff.lint.per-file-ignores]
"__init__.py" = ["F401"] # Ignore unused imports in __init__.py files
"tests/*" = ["S101"] # Ignore assert statements in tests

Expand Down

0 comments on commit d9d6543

Please sign in to comment.