diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 04923fcc..31efe55f 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -3,6 +3,13 @@ ci: skip: [hadolint-docker] repos: + # Autoupdate: Python code + - repo: https://github.com/asottile/pyupgrade + rev: v2.24.0 + hooks: + - id: pyupgrade + args: [--py39-plus] + # Autoformat: Python code - repo: https://github.com/psf/black rev: 21.7b0 diff --git a/docs/conf.py b/docs/conf.py index 17b16941..d6c75b04 100755 --- a/docs/conf.py +++ b/docs/conf.py @@ -1,5 +1,4 @@ #!/usr/bin/env python3 -# -*- coding: utf-8 -*- # # docker-stacks documentation build configuration file, created by # sphinx-quickstart on Fri Dec 29 20:32:10 2017. diff --git a/tagging/create_manifests.py b/tagging/create_manifests.py index e7c380e3..1eceba9d 100755 --- a/tagging/create_manifests.py +++ b/tagging/create_manifests.py @@ -5,7 +5,6 @@ import argparse import datetime import logging import os -from typing import List from .docker_runner import DockerRunner from .get_taggers_and_manifests import get_taggers_and_manifests from .git_helper import GitHelper @@ -23,7 +22,7 @@ def append_build_history_line( short_image_name: str, owner: str, wiki_path: str, - all_tags: List[str], + all_tags: list[str], ) -> None: logger.info("Appending build history line") @@ -43,7 +42,7 @@ def append_build_history_line( build_history_line = "|".join([date_column, image_column, links_column]) + "|" home_wiki_file = os.path.join(wiki_path, "Home.md") - with open(home_wiki_file, "r") as f: + with open(home_wiki_file) as f: file = f.read() TABLE_BEGINNING = "|-|-|-|\n" file = file.replace(TABLE_BEGINNING, TABLE_BEGINNING + build_history_line + "\n") @@ -55,7 +54,7 @@ def create_manifest_file( short_image_name: str, owner: str, wiki_path: str, - manifests: List[ManifestInterface], + manifests: list[ManifestInterface], container, ) -> None: manifest_names = [manifest.__name__ for manifest in manifests] diff --git a/tagging/get_taggers_and_manifests.py b/tagging/get_taggers_and_manifests.py index da8c201c..48fcc0b8 100644 --- a/tagging/get_taggers_and_manifests.py +++ b/tagging/get_taggers_and_manifests.py @@ -1,6 +1,5 @@ # Copyright (c) Jupyter Development Team. # Distributed under the terms of the Modified BSD License. -from typing import List, Tuple from .images_hierarchy import ALL_IMAGES from .manifests import ManifestInterface from .taggers import TaggerInterface @@ -8,9 +7,9 @@ from .taggers import TaggerInterface def get_taggers_and_manifests( short_image_name: str, -) -> Tuple[List[TaggerInterface], List[ManifestInterface]]: - taggers: List[TaggerInterface] = [] - manifests: List[ManifestInterface] = [] +) -> tuple[list[TaggerInterface], list[ManifestInterface]]: + taggers: list[TaggerInterface] = [] + manifests: list[ManifestInterface] = [] while short_image_name is not None: image_description = ALL_IMAGES[short_image_name] diff --git a/tagging/images_hierarchy.py b/tagging/images_hierarchy.py index 5c7f696b..16dc4553 100644 --- a/tagging/images_hierarchy.py +++ b/tagging/images_hierarchy.py @@ -1,7 +1,7 @@ # Copyright (c) Jupyter Development Team. # Distributed under the terms of the Modified BSD License. from dataclasses import dataclass, field -from typing import Optional, List +from typing import Optional from .taggers import ( TaggerInterface, SHATagger, @@ -31,8 +31,8 @@ from .manifests import ( @dataclass class ImageDescription: parent_image: Optional[str] - taggers: List[TaggerInterface] = field(default_factory=list) - manifests: List[ManifestInterface] = field(default_factory=list) + taggers: list[TaggerInterface] = field(default_factory=list) + manifests: list[ManifestInterface] = field(default_factory=list) ALL_IMAGES = {