Replace bandit, flake8, isort, and pyupgrade with ruff (#8178)

* Replace bandit, flake8, isort, and pyupgrade with ruff

* Comment on ruff rules

* updating DIRECTORY.md

---------

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
This commit is contained in:
Christian Clauss
2023-03-15 13:58:25 +01:00
committed by GitHub
parent adc3ccdabe
commit c96241b5a5
21 changed files with 127 additions and 132 deletions

View File

@ -6,13 +6,13 @@ to find edit distance.
The aim is to demonstate up bottom approach for solving the task.
The implementation was tested on the
leetcode: https://leetcode.com/problems/edit-distance/
"""
"""
Levinstein distance
Dynamic Programming: up -> down.
"""
import functools
def min_distance_up_bottom(word1: str, word2: str) -> int:
"""
@ -25,13 +25,10 @@ def min_distance_up_bottom(word1: str, word2: str) -> int:
>>> min_distance_up_bottom("zooicoarchaeologist", "zoologist")
10
"""
from functools import lru_cache
len_word1 = len(word1)
len_word2 = len(word2)
@lru_cache(maxsize=None)
@functools.cache
def min_distance(index1: int, index2: int) -> int:
# if first word index is overflow - delete all from the second word
if index1 >= len_word1:

View File

@ -22,7 +22,7 @@ Minimum Cost For Tickets
Dynamic Programming: up -> down.
"""
from functools import lru_cache
import functools
def mincost_tickets(days: list[int], costs: list[int]) -> int:
@ -106,7 +106,7 @@ def mincost_tickets(days: list[int], costs: list[int]) -> int:
days_set = set(days)
@lru_cache(maxsize=None)
@functools.cache
def dynamic_programming(index: int) -> int:
if index > 365:
return 0

View File

@ -20,7 +20,7 @@ Runtime: O(n * n)
Space: O(n)
"""
from functools import lru_cache
import functools
from typing import Any
@ -80,7 +80,7 @@ def word_break(string: str, words: list[str]) -> bool:
len_string = len(string)
# Dynamic programming method
@lru_cache(maxsize=None)
@functools.cache
def is_breakable(index: int) -> bool:
"""
>>> string = 'a'