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]
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

View File

@@ -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.

View File

@@ -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]

View File

@@ -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]

View File

@@ -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 = {