Add pyupgrade tool

This commit is contained in:
Ayaz Salikhov
2021-08-24 16:43:53 +03:00
parent 709f6750ef
commit ec9b7e9301
5 changed files with 16 additions and 12 deletions

View File

@@ -3,6 +3,13 @@ ci:
skip: [hadolint-docker] skip: [hadolint-docker]
repos: repos:
# Autoupdate: Python code
- repo: https://github.com/asottile/pyupgrade
rev: v2.24.0
hooks:
- id: pyupgrade
args: [--py39-plus]
# Autoformat: Python code # Autoformat: Python code
- repo: https://github.com/psf/black - repo: https://github.com/psf/black
rev: 21.7b0 rev: 21.7b0

View File

@@ -1,5 +1,4 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
# -*- coding: utf-8 -*-
# #
# docker-stacks documentation build configuration file, created by # docker-stacks documentation build configuration file, created by
# sphinx-quickstart on Fri Dec 29 20:32:10 2017. # sphinx-quickstart on Fri Dec 29 20:32:10 2017.

View File

@@ -5,7 +5,6 @@ import argparse
import datetime import datetime
import logging import logging
import os import os
from typing import List
from .docker_runner import DockerRunner from .docker_runner import DockerRunner
from .get_taggers_and_manifests import get_taggers_and_manifests from .get_taggers_and_manifests import get_taggers_and_manifests
from .git_helper import GitHelper from .git_helper import GitHelper
@@ -23,7 +22,7 @@ def append_build_history_line(
short_image_name: str, short_image_name: str,
owner: str, owner: str,
wiki_path: str, wiki_path: str,
all_tags: List[str], all_tags: list[str],
) -> None: ) -> None:
logger.info("Appending build history line") 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]) + "|" build_history_line = "|".join([date_column, image_column, links_column]) + "|"
home_wiki_file = os.path.join(wiki_path, "Home.md") 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() file = f.read()
TABLE_BEGINNING = "|-|-|-|\n" TABLE_BEGINNING = "|-|-|-|\n"
file = file.replace(TABLE_BEGINNING, TABLE_BEGINNING + build_history_line + "\n") file = file.replace(TABLE_BEGINNING, TABLE_BEGINNING + build_history_line + "\n")
@@ -55,7 +54,7 @@ def create_manifest_file(
short_image_name: str, short_image_name: str,
owner: str, owner: str,
wiki_path: str, wiki_path: str,
manifests: List[ManifestInterface], manifests: list[ManifestInterface],
container, container,
) -> None: ) -> None:
manifest_names = [manifest.__name__ for manifest in manifests] manifest_names = [manifest.__name__ for manifest in manifests]

View File

@@ -1,6 +1,5 @@
# Copyright (c) Jupyter Development Team. # Copyright (c) Jupyter Development Team.
# Distributed under the terms of the Modified BSD License. # Distributed under the terms of the Modified BSD License.
from typing import List, Tuple
from .images_hierarchy import ALL_IMAGES from .images_hierarchy import ALL_IMAGES
from .manifests import ManifestInterface from .manifests import ManifestInterface
from .taggers import TaggerInterface from .taggers import TaggerInterface
@@ -8,9 +7,9 @@ from .taggers import TaggerInterface
def get_taggers_and_manifests( def get_taggers_and_manifests(
short_image_name: str, short_image_name: str,
) -> Tuple[List[TaggerInterface], List[ManifestInterface]]: ) -> tuple[list[TaggerInterface], list[ManifestInterface]]:
taggers: List[TaggerInterface] = [] taggers: list[TaggerInterface] = []
manifests: List[ManifestInterface] = [] manifests: list[ManifestInterface] = []
while short_image_name is not None: while short_image_name is not None:
image_description = ALL_IMAGES[short_image_name] image_description = ALL_IMAGES[short_image_name]

View File

@@ -1,7 +1,7 @@
# Copyright (c) Jupyter Development Team. # Copyright (c) Jupyter Development Team.
# Distributed under the terms of the Modified BSD License. # Distributed under the terms of the Modified BSD License.
from dataclasses import dataclass, field from dataclasses import dataclass, field
from typing import Optional, List from typing import Optional
from .taggers import ( from .taggers import (
TaggerInterface, TaggerInterface,
SHATagger, SHATagger,
@@ -31,8 +31,8 @@ from .manifests import (
@dataclass @dataclass
class ImageDescription: class ImageDescription:
parent_image: Optional[str] parent_image: Optional[str]
taggers: List[TaggerInterface] = field(default_factory=list) taggers: list[TaggerInterface] = field(default_factory=list)
manifests: List[ManifestInterface] = field(default_factory=list) manifests: list[ManifestInterface] = field(default_factory=list)
ALL_IMAGES = { ALL_IMAGES = {