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
3 changes: 2 additions & 1 deletion .github/.platforms/generate_platforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@
import sys
import tempfile
import time
from collections.abc import Callable
from dataclasses import dataclass
from pathlib import Path
from typing import Callable, TypeVar
from typing import TypeVar

# Configuration
PYTHON_VERSIONS = ("3.10", "3.11", "3.12", "3.13", "3.14")
Expand Down
10 changes: 6 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,12 @@ repos:
hooks:
- id: isort

- repo: https://github.com/asottile/pyupgrade
rev: v3.19.1
hooks:
- id: pyupgrade
- repo: https://github.com/asottile/pyupgrade
rev: v3.21.2
hooks:
- id: pyupgrade
args: [--py310-plus]


- repo: https://github.com/zizmorcore/zizmor-pre-commit
rev: v1.20.0
Expand Down
5 changes: 2 additions & 3 deletions cloudsmith_cli/cli/commands/mcp.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import shutil
import sys
from pathlib import Path
from typing import Dict, List

import click
import json5
Expand Down Expand Up @@ -110,7 +109,7 @@ def list_groups(ctx, opts, mcp_server: server.DynamicMCPServer):
print_groups(groups)


def print_tools(tool_list: Dict[str, OpenAPITool]):
def print_tools(tool_list: dict[str, OpenAPITool]):
"""Print tools as a table or output in another format."""

headers = [
Expand Down Expand Up @@ -138,7 +137,7 @@ def print_tools(tool_list: Dict[str, OpenAPITool]):
utils.pretty_print_list_info(num_results=num_results, suffix=list_suffix)


def print_groups(group_list: Dict[str, List[str]]):
def print_groups(group_list: dict[str, list[str]]):
"""Print tool groups as a table or output in another format."""

headers = [
Expand Down
8 changes: 3 additions & 5 deletions cloudsmith_cli/cli/saml.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def get_idp_url(api_host, owner, session):

def exchange_2fa_token(api_host, two_factor_token, totp_token, session):
exchange_data = {"two_factor_token": two_factor_token, "totp_token": totp_token}
exchange_url = "{api_host}/user/two-factor/".format(api_host=api_host)
exchange_url = f"{api_host}/user/two-factor/"

headers = {
"Authorization": "Bearer {two_factor_token}".format(
Expand Down Expand Up @@ -82,11 +82,9 @@ def exchange_2fa_token(api_host, two_factor_token, totp_token, session):

def refresh_access_token(api_host, access_token, refresh_token, session):
data = {"refresh_token": refresh_token}
url = "{api_host}/user/refresh-token/".format(api_host=api_host)
url = f"{api_host}/user/refresh-token/"

headers = {
"Authorization": "Bearer {access_token}".format(access_token=access_token)
}
headers = {"Authorization": f"Bearer {access_token}"}

response = session.post(
url,
Expand Down
4 changes: 2 additions & 2 deletions cloudsmith_cli/core/api/init.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Cloudsmith API - Initialisation."""

import base64
from typing import Type, TypeVar
from typing import TypeVar

import click
import cloudsmith_api
Expand Down Expand Up @@ -128,7 +128,7 @@ def initialise_api(
T = TypeVar("T")


def get_api_client(cls: Type[T]) -> T:
def get_api_client(cls: type[T]) -> T:
"""Get an API client (with configuration)."""
config = cloudsmith_api.Configuration()
client = cls()
Expand Down
12 changes: 6 additions & 6 deletions cloudsmith_cli/core/api/metadata.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""API - Package metadata (v2) endpoints."""

import json
from typing import Any, Optional, Union
from typing import Any

import cloudsmith_api

Expand Down Expand Up @@ -136,10 +136,10 @@ def _response_json(response):
def list_metadata(
package_slug_perm: str,
*,
source_kind: Optional[Union[int, str]] = None,
classification: Optional[Union[int, str]] = None,
page: Optional[int] = None,
page_size: Optional[int] = None,
source_kind: int | str | None = None,
classification: int | str | None = None,
page: int | None = None,
page_size: int | None = None,
):
"""List metadata entries attached to a package.

Expand Down Expand Up @@ -216,7 +216,7 @@ def update_metadata(
metadata_slug_perm: str,
*,
content: Any = None,
source_identity: Optional[str] = None,
source_identity: str | None = None,
):
"""Patch an existing customer-owned metadata entry.

Expand Down
61 changes: 30 additions & 31 deletions cloudsmith_cli/core/download.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import fnmatch
import hashlib
import os
from typing import Dict, List, Optional, Tuple

import click
import cloudsmith_api
Expand All @@ -18,8 +17,8 @@


def resolve_auth(
opts, api_key_opt: Optional[str] = None
) -> Tuple[requests.Session, Dict[str, str], str]:
opts, api_key_opt: str | None = None
) -> tuple[requests.Session, dict[str, str], str]:
"""
Resolve authentication method and create session with appropriate headers.

Expand Down Expand Up @@ -56,7 +55,7 @@ def resolve_auth(
return session, headers, auth_source


def _matches_tag_filter(pkg: Dict, tag_filter: str) -> bool:
def _matches_tag_filter(pkg: dict, tag_filter: str) -> bool:
"""
Check if a package matches the tag filter.

Expand Down Expand Up @@ -84,13 +83,13 @@ def _search_packages(
repo: str,
name: str,
*,
version: Optional[str] = None,
format_filter: Optional[str] = None,
os_filter: Optional[str] = None,
arch_filter: Optional[str] = None,
tag_filter: Optional[str] = None,
filename_filter: Optional[str] = None,
) -> List[Dict]:
version: str | None = None,
format_filter: str | None = None,
os_filter: str | None = None,
arch_filter: str | None = None,
tag_filter: str | None = None,
filename_filter: str | None = None,
) -> list[dict]:
"""
Search for packages matching criteria, returning all matches.

Expand Down Expand Up @@ -172,13 +171,13 @@ def resolve_all_packages(
repo: str,
name: str,
*,
version: Optional[str] = None,
format_filter: Optional[str] = None,
os_filter: Optional[str] = None,
arch_filter: Optional[str] = None,
tag_filter: Optional[str] = None,
filename_filter: Optional[str] = None,
) -> List[Dict]:
version: str | None = None,
format_filter: str | None = None,
os_filter: str | None = None,
arch_filter: str | None = None,
tag_filter: str | None = None,
filename_filter: str | None = None,
) -> list[dict]:
"""
Find all packages matching the criteria.

Expand Down Expand Up @@ -224,14 +223,14 @@ def resolve_package(
repo: str,
name: str,
*,
version: Optional[str] = None,
format_filter: Optional[str] = None,
os_filter: Optional[str] = None,
arch_filter: Optional[str] = None,
tag_filter: Optional[str] = None,
filename_filter: Optional[str] = None,
version: str | None = None,
format_filter: str | None = None,
os_filter: str | None = None,
arch_filter: str | None = None,
tag_filter: str | None = None,
filename_filter: str | None = None,
yes: bool = False,
) -> Dict:
) -> dict:
"""
Find a single package matching the criteria, handling multiple matches.

Expand Down Expand Up @@ -295,7 +294,7 @@ def resolve_package(
return best_package


def _display_multiple_packages(packages: List[Dict]) -> None:
def _display_multiple_packages(packages: list[dict]) -> None:
"""Display a table of multiple matching packages."""
click.echo("Multiple packages found:")
click.echo()
Expand All @@ -319,7 +318,7 @@ def _display_multiple_packages(packages: List[Dict]) -> None:
click.echo()


def get_download_url(package: Dict) -> str:
def get_download_url(package: dict) -> str:
"""
Get the download URL for a package.

Expand All @@ -346,7 +345,7 @@ def get_download_url(package: Dict) -> str:
return download_url


def get_package_files(package: Dict) -> List[Dict]:
def get_package_files(package: dict) -> list[dict]:
"""
Get all downloadable files associated with a package.

Expand Down Expand Up @@ -389,7 +388,7 @@ def get_package_files(package: Dict) -> List[Dict]:
return downloadable_files


def get_package_detail(owner: str, repo: str, identifier: str) -> Dict:
def get_package_detail(owner: str, repo: str, identifier: str) -> dict:
"""
Get detailed package information including download URLs.

Expand Down Expand Up @@ -417,7 +416,7 @@ def stream_download( # noqa: C901
outfile: str,
session: requests.Session,
*,
headers: Optional[Dict[str, str]] = None,
headers: dict[str, str] | None = None,
overwrite: bool = False,
quiet: bool = False,
) -> None:
Expand Down Expand Up @@ -522,7 +521,7 @@ def stream_download( # noqa: C901
click.secho("⚠ Checksum mismatch", fg="yellow", err=True)


def _select_best_package(packages: List[Dict]) -> Dict:
def _select_best_package(packages: list[dict]) -> dict:
"""Select the best package from multiple matches."""

# Sort by version (desc) then by upload date (desc)
Expand Down
6 changes: 3 additions & 3 deletions cloudsmith_cli/core/mcp/data.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from dataclasses import dataclass
from typing import Any, Dict, Optional
from typing import Any


@dataclass
Expand All @@ -10,8 +10,8 @@ class OpenAPITool:
description: str
method: str
path: str
parameters: Dict[str, Any]
parameters: dict[str, Any]
base_url: str
query_filter: Optional[str]
query_filter: str | None
is_destructive: bool = False
is_read_only: bool = False
Loading
Loading