1
0
Fork 0
mirror of https://github.com/Findus23/lw1.at.git synced 2024-09-11 06:23:44 +02:00

pyupgrade

This commit is contained in:
Lukas Winkler 2023-04-25 22:24:39 +02:00
parent 67a84d91b8
commit 013d4e384d
Signed by: lukas
GPG key ID: 54DE4D798D244853
7 changed files with 15 additions and 16 deletions

View file

@ -12,7 +12,7 @@ from lw1.paths import cache_dir, output_dir
from lw1.utils import short_hash, hash_file
def logged_run(cmd: List[str]):
def logged_run(cmd: list[str]):
print(cmd)
run(cmd, check=True)
@ -72,11 +72,11 @@ def logged_move(source: Path, target: Path):
class File:
def __init__(self, source_file: Path, type: Optional[Path] = None):
def __init__(self, source_file: Path, type: Path | None = None):
self.source_file = source_file
self.type = type
self.public_url: Optional[str] = None
self.target_file: Optional[str] = None
self.public_url: str | None = None
self.target_file: str | None = None
@property
def modtime(self) -> float:

View file

@ -27,7 +27,7 @@ class Generator(ABC):
js_entry_point = "assets/main.ts"
type = ""
def __init__(self, translations: Translations, context: Dict, posts: List[Post], tags: Dict[str, Tag],
def __init__(self, translations: Translations, context: dict, posts: list[Post], tags: dict[str, Tag],
lang: Language, sitemap: Sitemap):
self.posts = posts
self.tags = tags

View file

@ -15,7 +15,7 @@ from lw1.utils import Language
class PostLoader():
@staticmethod
def load_posts() -> List[Post]:
def load_posts() -> list[Post]:
posts = []
for post_dir in content_dir.glob("*"):
if not post_dir.is_dir():
@ -32,7 +32,7 @@ class PostLoader():
all_meta[lang]["markdown"] = (post_dir / f"{lang}.md").read_text()
except FileNotFoundError:
continue
postgroup: List[Post] = []
postgroup: list[Post] = []
for lang in LANGUAGES:
fallback_lang = FALLBACK_LANGUAGES[lang]
data = all_meta | all_meta[fallback_lang] | all_meta[lang]
@ -56,7 +56,7 @@ class PostLoader():
class TagsLoader():
@staticmethod
def load_tags() -> Dict[str, Tag]:
def load_tags() -> dict[str, Tag]:
tags = {}
with (content_dir / "tags.yaml").open() as f:
tag_data = yaml.load(f, Loader=CSafeLoader)
@ -75,7 +75,7 @@ class TagsLoader():
class AssetsLoader():
@staticmethod
def load_entrypoints(debug=False) -> Dict[str, str]:
def load_entrypoints(debug=False) -> dict[str, str]:
if debug:
return {
"assets/main.ts": "assets/main.js",

View file

@ -4,7 +4,6 @@ from dataclasses import dataclass
from datetime import datetime
from functools import cached_property
from pathlib import Path
from typing import Dict, List
from babel import dates
from markupsafe import Markup
@ -32,7 +31,7 @@ class iFrame:
@dataclass
class Post:
title: str
tags: List[str]
tags: list[str]
date: datetime
markdown: str
content_img: Image
@ -52,7 +51,7 @@ class Post:
other_lang_post: Post = None
@classmethod
def from_meta(cls, meta: Dict):
def from_meta(cls, meta: dict):
if "license" in meta:
meta["license"] = License(**meta["license"])
if "iframe" in meta:

View file

@ -2,9 +2,9 @@ from typing import List, Dict
from lw1.utils import Language
LANGUAGES: List[Language] = ["en", "de"]
LANGUAGES: list[Language] = ["en", "de"]
FALLBACK_LANGUAGES: Dict[Language, Language] = {
FALLBACK_LANGUAGES: dict[Language, Language] = {
"en": "de",
"de": "en"
}

View file

@ -11,7 +11,7 @@ class Sitemap:
ElementTree.register_namespace("", "http://www.sitemaps.org/schemas/sitemap/0.9")
self.root = ElementTree.Element("{http://www.sitemaps.org/schemas/sitemap/0.9}urlset")
def add_page(self, context: Dict) -> None:
def add_page(self, context: dict) -> None:
cur_url = f"https://lw1.at{context['url']}"
lang = context["lang"]
otherlang_url = f"https://lw1.at{context['otherlang_url']}"

View file

@ -10,7 +10,7 @@ from watchfiles.main import FileChange, watch
from lw1.main import main
def callback(changes: Set[FileChange]):
def callback(changes: set[FileChange]):
print("changed:")
for change, file in changes:
print("-", file.split("../")[-1])