diff --git a/lib/pyapi/core.py b/lib/pyapi/core.py index 3eb4f01ee6..33f8257004 100644 --- a/lib/pyapi/core.py +++ b/lib/pyapi/core.py @@ -6,18 +6,18 @@ from __future__ import annotations import json +from dataclasses import dataclass from pathlib import Path from typing import TYPE_CHECKING if TYPE_CHECKING: - from typing import TypedDict - from npe2 import PluginManifest Version = str PluginName = str - class Plugins(TypedDict): + @dataclass + class Plugins: active: dict[PluginName, list[Version]] withdrawn: dict[PluginName, list[Version]] deleted: dict[PluginName, list[Version]] diff --git a/lib/pyapi/github.py b/lib/pyapi/github.py index 4d3f51d335..c2978ae957 100644 --- a/lib/pyapi/github.py +++ b/lib/pyapi/github.py @@ -1,10 +1,11 @@ import json import os import re +from dataclasses import dataclass from functools import lru_cache from itertools import chain from pathlib import Path -from typing import Literal, TypedDict +from typing import Literal import requests from gql import Client, gql @@ -16,14 +17,16 @@ PluginName = str -class CommitInfo(TypedDict): +@dataclass +class CommitInfo: date: str message: str author_name: str author_login: str -class GithubActivity(TypedDict): +@dataclass +class GithubActivity: default_branch: str open_issues: int pull_requests: int @@ -35,7 +38,8 @@ class GithubActivity(TypedDict): open_runtime_vulnerability_alerts: int -class CoverageInfo(TypedDict): +@dataclass +class CoverageInfo: hits: int lines: int ratio: float @@ -44,7 +48,8 @@ class CoverageInfo(TypedDict): branch: str -class RepoSummary(TypedDict): +@dataclass +class RepoSummary: url: str activity: GithubActivity coverage: CoverageInfo | None diff --git a/scripts/fetch_manifests.py b/scripts/fetch_manifests.py index b91397a7d7..b32e4da6d3 100644 --- a/scripts/fetch_manifests.py +++ b/scripts/fetch_manifests.py @@ -11,8 +11,8 @@ import json import sys from concurrent.futures import ProcessPoolExecutor +from dataclasses import dataclass from pathlib import Path -from typing import TypedDict from npe2 import fetch_manifest from packaging.version import Version @@ -41,7 +41,8 @@ def _current_manifest_is_valid(name: str, version: str) -> bool: return False -class ManifestError(TypedDict): +@dataclass +class ManifestError: name: str version: str error: str diff --git a/scripts/reindex.py b/scripts/reindex.py index f0ef5cbd67..15753eeafc 100644 --- a/scripts/reindex.py +++ b/scripts/reindex.py @@ -13,8 +13,9 @@ import re import sys from concurrent.futures import ThreadPoolExecutor +from dataclasses import dataclass from pathlib import Path -from typing import Any, TypedDict +from typing import Any from urllib import error, request from packaging.utils import canonicalize_name @@ -33,7 +34,8 @@ PluginName = str -class SummaryDict(TypedDict): +@dataclass +class SummaryDict: """Structure of dicts in index.json.""" normalized_name: str