mirror of
https://github.com/pre-commit/pre-commit-hooks.git
synced 2026-04-05 03:26:53 +00:00
drop python3.6 support
python 3.6 reached end of life on 2021-12-23 Committed via https://github.com/asottile/all-repos
This commit is contained in:
parent
2aef4c777f
commit
8f6152921e
76 changed files with 229 additions and 145 deletions
|
|
@ -17,16 +17,16 @@ We assume a strict subset of YAML that looks like:
|
|||
In other words, we don't sort deeper than the top layer, and might corrupt
|
||||
complicated YAML files.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
from typing import List
|
||||
from typing import Optional
|
||||
from typing import Sequence
|
||||
|
||||
|
||||
QUOTES = ["'", '"']
|
||||
|
||||
|
||||
def sort(lines: List[str]) -> List[str]:
|
||||
def sort(lines: list[str]) -> list[str]:
|
||||
"""Sort a YAML file in alphabetical order, keeping blocks together.
|
||||
|
||||
:param lines: array of strings (without newlines)
|
||||
|
|
@ -44,7 +44,7 @@ def sort(lines: List[str]) -> List[str]:
|
|||
return new_lines
|
||||
|
||||
|
||||
def parse_block(lines: List[str], header: bool = False) -> List[str]:
|
||||
def parse_block(lines: list[str], header: bool = False) -> list[str]:
|
||||
"""Parse and return a single block, popping off the start of `lines`.
|
||||
|
||||
If parsing a header block, we stop after we reach a line that is not a
|
||||
|
|
@ -60,7 +60,7 @@ def parse_block(lines: List[str], header: bool = False) -> List[str]:
|
|||
return block_lines
|
||||
|
||||
|
||||
def parse_blocks(lines: List[str]) -> List[List[str]]:
|
||||
def parse_blocks(lines: list[str]) -> list[list[str]]:
|
||||
"""Parse and return all possible blocks, popping off the start of `lines`.
|
||||
|
||||
:param lines: list of lines
|
||||
|
|
@ -77,7 +77,7 @@ def parse_blocks(lines: List[str]) -> List[List[str]]:
|
|||
return blocks
|
||||
|
||||
|
||||
def first_key(lines: List[str]) -> str:
|
||||
def first_key(lines: list[str]) -> str:
|
||||
"""Returns a string representing the sort key of a block.
|
||||
|
||||
The sort key is the first YAML key we encounter, ignoring comments, and
|
||||
|
|
@ -99,7 +99,7 @@ def first_key(lines: List[str]) -> str:
|
|||
return '' # not actually reached in reality
|
||||
|
||||
|
||||
def main(argv: Optional[Sequence[str]] = None) -> int:
|
||||
def main(argv: Sequence[str] | None = None) -> int:
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('filenames', nargs='*', help='Filenames to fix')
|
||||
args = parser.parse_args(argv)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue