|
18 | 18 |
|
19 | 19 | console = Console(stderr=True) |
20 | 20 |
|
21 | | -DEFAULT_CATALOG_URL = ( |
22 | | - "https://raw.githubusercontent.com/Create-Python-App/cpa-templates/main/templates.json" |
23 | | -) |
| 21 | +DEFAULT_CATALOG_URL = "https://raw.githubusercontent.com/Create-Python-App/cpa-templates/main/templates.json" |
24 | 22 | CACHE_TTL_SECONDS = 3600 |
25 | 23 | FETCH_TIMEOUT_SECONDS = 10 |
26 | 24 | USER_AGENT = f"create-awesome-python-app/{__version__} (https://github.com/Create-Python-App/create-python-app)" |
@@ -111,22 +109,31 @@ def get_catalog_data(*, force_refresh: bool = False) -> dict[str, Any]: |
111 | 109 | try: |
112 | 110 | data = _fetch_remote(url) |
113 | 111 | _write_disk_cache(data) |
114 | | - except (urllib.error.URLError, TimeoutError, OSError, json.JSONDecodeError) as err: |
| 112 | + except ( |
| 113 | + urllib.error.URLError, |
| 114 | + TimeoutError, |
| 115 | + OSError, |
| 116 | + json.JSONDecodeError, |
| 117 | + ) as err: |
115 | 118 | disk = _read_disk_cache() |
116 | 119 | if disk is not None: |
117 | 120 | console.print( |
118 | | - f"[yellow][cpa] Could not refresh catalog ({err}); using disk cache.[/yellow]" |
| 121 | + "[yellow][cpa] Could not refresh catalog " |
| 122 | + f"({err}); using disk cache.[/yellow]" |
119 | 123 | ) |
120 | 124 | data = disk |
121 | 125 | else: |
122 | 126 | fixture = _read_fixture() |
123 | 127 | if fixture.get("templates"): |
124 | 128 | console.print( |
125 | | - f"[yellow][cpa] Could not refresh catalog ({err}); using fixture.[/yellow]" |
| 129 | + "[yellow][cpa] Could not refresh catalog " |
| 130 | + f"({err}); using fixture.[/yellow]" |
126 | 131 | ) |
127 | 132 | data = fixture |
128 | 133 | else: |
129 | | - raise RuntimeError(f"Failed to load template catalog: {err}") from err |
| 134 | + raise RuntimeError( |
| 135 | + f"Failed to load template catalog: {err}" |
| 136 | + ) from err |
130 | 137 |
|
131 | 138 | _memory_cache = data |
132 | 139 | _memory_ts = time.time() |
@@ -173,7 +180,9 @@ def list_addons(template_slug: str | None = None) -> None: |
173 | 180 | ext_types = [ext_types] |
174 | 181 | if template_type and template_type not in ext_types: |
175 | 182 | continue |
176 | | - type_label = ", ".join(ext_types) if isinstance(ext_types, list) else str(ext_types) |
| 183 | + type_label = ( |
| 184 | + ", ".join(ext_types) if isinstance(ext_types, list) else str(ext_types) |
| 185 | + ) |
177 | 186 | table.add_row( |
178 | 187 | str(ext.get("slug", "")), |
179 | 188 | str(ext.get("category", "")), |
|
0 commit comments