Pyupgrade to Python 3.9 (#4718)

* Pyupgrade to Python 3.9

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
This commit is contained in:
Christian Clauss
2021-09-07 13:37:03 +02:00
committed by GitHub
parent 5d5831bdd0
commit cecf43d648
142 changed files with 523 additions and 530 deletions

View File

@ -1,7 +1,8 @@
from __future__ import annotations
from bisect import bisect_left
from functools import total_ordering
from heapq import merge
from typing import List
"""
A pure Python implementation of the patience sort algorithm
@ -44,7 +45,7 @@ def patience_sort(collection: list) -> list:
>>> patience_sort([-3, -17, -48])
[-48, -17, -3]
"""
stacks: List[Stack] = []
stacks: list[Stack] = []
# sort into stacks
for element in collection:
new_stacks = Stack([element])
@ -55,7 +56,7 @@ def patience_sort(collection: list) -> list:
stacks.append(new_stacks)
# use a heap-based merge to merge stack efficiently
collection[:] = merge(*[reversed(stack) for stack in stacks])
collection[:] = merge(*(reversed(stack) for stack in stacks))
return collection