Skip to content

Commit 280f693

Browse files
authored
Merge branch 'python-poetry:main' into logging_integration
2 parents cca3f85 + aefc890 commit 280f693

27 files changed

+56
-167
lines changed

.github/workflows/tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
strategy:
1616
matrix:
1717
os: [Ubuntu, macOS, Windows]
18-
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
18+
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
1919
include:
2020
- os: Ubuntu
2121
image: ubuntu-22.04

.pre-commit-config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ ci:
44

55
repos:
66
- repo: https://github.com/pre-commit/pre-commit-hooks
7-
rev: v4.6.0
7+
rev: v5.0.0
88
hooks:
99
- id: trailing-whitespace
1010
exclude: ^(.*\.egg-info/|tests/(fixtures|ui).*)$
@@ -22,7 +22,7 @@ repos:
2222
- id: check-docstring-first
2323

2424
- repo: https://github.com/astral-sh/ruff-pre-commit
25-
rev: v0.6.3
25+
rev: v0.7.2
2626
hooks:
2727
- id: ruff
2828
- id: ruff-format

news/439.feat.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Add support for Python 3.13.

news/439.removal.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Dropped support for Python 3.8.

news/442.deps.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Removed `rapidfuzz` dependency

poetry.lock

Lines changed: 4 additions & 119 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,7 @@ classifiers = [
3333
]
3434

3535
[tool.poetry.dependencies]
36-
python = "^3.8"
37-
rapidfuzz = "^3.0.0"
36+
python = "^3.9"
3837

3938
[tool.poetry.group.dev.dependencies]
4039
mypy = "^1.5"
@@ -50,7 +49,7 @@ furo = "^2023.9.10"
5049

5150
[tool.ruff]
5251
fix = true
53-
target-version = "py38"
52+
target-version = "py39"
5453
line-length = 88
5554
extend-exclude = [
5655
"docs/*",

src/cleo/_utils.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,9 @@
33
import math
44

55
from dataclasses import dataclass
6+
from difflib import SequenceMatcher
67
from html.parser import HTMLParser
78

8-
from rapidfuzz.distance import Levenshtein
9-
109

1110
class TagStripper(HTMLParser):
1211
def __init__(self) -> None:
@@ -51,12 +50,12 @@ def find_similar_names(name: str, names: list[str]) -> list[str]:
5150
"""
5251
Finds names similar to a given command name.
5352
"""
54-
threshold = 1e3
53+
threshold = 0.4
5554
distance_by_name = {}
56-
55+
if " " in name:
56+
names = [name for name in names if " " in name]
5757
for actual_name in names:
58-
# Get Levenshtein distance between the input and each command name
59-
distance = Levenshtein.distance(name, actual_name)
58+
distance = SequenceMatcher(None, actual_name, name).ratio()
6059

6160
is_similar = distance <= len(name) / 3
6261
substring_index = actual_name.find(name)
@@ -70,9 +69,7 @@ def find_similar_names(name: str, names: list[str]) -> list[str]:
7069

7170
# Only keep results with a distance below the threshold
7271
distance_by_name = {
73-
key: value
74-
for key, value in distance_by_name.items()
75-
if value[0] < 2 * threshold
72+
key: value for key, value in distance_by_name.items() if value[0] > threshold
7673
}
7774
# Display results with shortest distance first
7875
return sorted(distance_by_name, key=lambda key: distance_by_name[key])

src/cleo/commands/command.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
from typing import TYPE_CHECKING
66
from typing import Any
77
from typing import ClassVar
8-
from typing import ContextManager
98
from typing import cast
109

1110
from cleo.exceptions import CleoError
@@ -18,6 +17,7 @@
1817

1918

2019
if TYPE_CHECKING:
20+
from contextlib import AbstractContextManager
2121
from typing import Literal
2222

2323
from cleo.application import Application
@@ -412,7 +412,7 @@ def spin(
412412
fmt: str | None = None,
413413
interval: int = 100,
414414
values: list[str] | None = None,
415-
) -> ContextManager[ProgressIndicator]:
415+
) -> AbstractContextManager[ProgressIndicator]:
416416
"""
417417
Automatically spin a progress indicator.
418418
"""

src/cleo/descriptors/text_descriptor.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
from typing import TYPE_CHECKING
77
from typing import Any
8-
from typing import Sequence
98

109
from cleo.commands.command import Command
1110
from cleo.descriptors.descriptor import Descriptor
@@ -14,6 +13,8 @@
1413

1514

1615
if TYPE_CHECKING:
16+
from collections.abc import Sequence
17+
1718
from cleo.application import Application
1819
from cleo.io.inputs.argument import Argument
1920
from cleo.io.inputs.option import Option

0 commit comments

Comments
 (0)