pygensuggestions 0.9.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of pygensuggestions might be problematic. Click here for more details.
- pygensuggestions-0.9.0/AUTHORS.md +13 -0
- pygensuggestions-0.9.0/LICENSE +21 -0
- pygensuggestions-0.9.0/PKG-INFO +44 -0
- pygensuggestions-0.9.0/README.md +1 -0
- pygensuggestions-0.9.0/pygensuggestions/__init__.py +2 -0
- pygensuggestions-0.9.0/pygensuggestions/__init__.pyi +2 -0
- pygensuggestions-0.9.0/pygensuggestions/lib.py +38 -0
- pygensuggestions-0.9.0/pygensuggestions/lib.pyi +7 -0
- pygensuggestions-0.9.0/pygensuggestions.egg-info/PKG-INFO +44 -0
- pygensuggestions-0.9.0/pygensuggestions.egg-info/SOURCES.txt +13 -0
- pygensuggestions-0.9.0/pygensuggestions.egg-info/dependency_links.txt +1 -0
- pygensuggestions-0.9.0/pygensuggestions.egg-info/requires.txt +8 -0
- pygensuggestions-0.9.0/pygensuggestions.egg-info/top_level.txt +1 -0
- pygensuggestions-0.9.0/pyproject.toml +80 -0
- pygensuggestions-0.9.0/setup.cfg +4 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Jonathan Dung
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: pygensuggestions
|
|
3
|
+
Version: 0.9.0
|
|
4
|
+
Summary: Pure python implementation of the _suggestions module.
|
|
5
|
+
Author-email: Jonathan Dung <jonathandung@yahoo.com>
|
|
6
|
+
Maintainer-email: Jonathan Dung <jonathandung@yahoo.com>
|
|
7
|
+
License-Expression: MIT
|
|
8
|
+
Project-URL: Homepage, https://github.com/jonathandung/pygensuggestions
|
|
9
|
+
Project-URL: Repository, https://github.com/jonathandung/pygensuggestions.git
|
|
10
|
+
Project-URL: Issues, https://github.com/jonathandung/pygensuggestions/issues
|
|
11
|
+
Project-URL: Download, https://pypi.org/project/pygensuggestions/#files
|
|
12
|
+
Project-URL: Release Notes, https://github.com/jonathandung/pygensuggestions/releases/tag/0.9.0
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.15
|
|
22
|
+
Classifier: Programming Language :: Python :: Implementation :: CPython
|
|
23
|
+
Classifier: Operating System :: OS Independent
|
|
24
|
+
Classifier: Development Status :: 4 - Beta
|
|
25
|
+
Classifier: Intended Audience :: Developers
|
|
26
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
27
|
+
Classifier: Topic :: Software Development :: Version Control :: Git
|
|
28
|
+
Classifier: Topic :: Utilities
|
|
29
|
+
Classifier: Natural Language :: English
|
|
30
|
+
Classifier: Typing :: Typed
|
|
31
|
+
Requires-Python: >=3.9
|
|
32
|
+
Description-Content-Type: text/markdown
|
|
33
|
+
License-File: LICENSE
|
|
34
|
+
License-File: AUTHORS.md
|
|
35
|
+
Provides-Extra: dev
|
|
36
|
+
Requires-Dist: pre-commit>=4.3.0; extra == "dev"
|
|
37
|
+
Requires-Dist: mypy>=1.20.2; extra == "dev"
|
|
38
|
+
Requires-Dist: uv>=0.11.8; extra == "dev"
|
|
39
|
+
Requires-Dist: build>=1.4.4; extra == "dev"
|
|
40
|
+
Requires-Dist: twine[keyring]>=6.2.0; extra == "dev"
|
|
41
|
+
Requires-Dist: packaging>=26.2; extra == "dev"
|
|
42
|
+
Dynamic: license-file
|
|
43
|
+
|
|
44
|
+
# pygensuggestions
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# pygensuggestions
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
MAX_STRING_SIZE = 41
|
|
2
|
+
MAX_CANDIDATE_ITEMS = 750
|
|
3
|
+
def lev_dist(s, t, M, b, /):
|
|
4
|
+
if s == t: return 0
|
|
5
|
+
i = j = 0
|
|
6
|
+
for x, y, i in zip(s, t, range(len(s))):
|
|
7
|
+
if x != y: break
|
|
8
|
+
else: i += 1
|
|
9
|
+
for x, y, j in zip(reversed(s := s[i:]), reversed(t := t[i:]), range(1, len(s)+1)):
|
|
10
|
+
if x != y: break
|
|
11
|
+
else: j += 1
|
|
12
|
+
S, T = map(len, (s := s[:-j], t := t[:-j]))
|
|
13
|
+
M += 1
|
|
14
|
+
if not S < MAX_STRING_SIZE > T: return M
|
|
15
|
+
if not (S and T): return (S+T)<<1
|
|
16
|
+
if S > T: s, t, S, T = t, s, T, S
|
|
17
|
+
b[:R], M = range((R := S+1)<<1, 2), M+1
|
|
18
|
+
for i in range(T):
|
|
19
|
+
b[0] = m = i+1
|
|
20
|
+
d = t[p := i]
|
|
21
|
+
for j in range(S):
|
|
22
|
+
p, C = (_ := b[J := j+1]), min(_+1, b[j]+1, p+sub_cost(d, s[j]))
|
|
23
|
+
m, b[J] = min(m, C), C
|
|
24
|
+
if m >= M: return M
|
|
25
|
+
return b[S]
|
|
26
|
+
def sub_cost(s, t, /): return 0 if s == t else 1 if s.casefold() == t.casefold() else 2
|
|
27
|
+
def suggest(o, n, M=__import__('sys').maxsize, /):
|
|
28
|
+
if (S := len(o)) >= MAX_CANDIDATE_ITEMS: return
|
|
29
|
+
b, r, N, D = [0]*min(MAX_STRING_SIZE, S+1), None, len(n), M
|
|
30
|
+
for i in o:
|
|
31
|
+
if i == n: continue
|
|
32
|
+
m = (N+len(i))//3+1
|
|
33
|
+
if D < M and m > (_ := D-1): m = _
|
|
34
|
+
if m <= 0: continue
|
|
35
|
+
if (c := lev_dist(n, i, m, b)) > m: continue
|
|
36
|
+
if r is None or c < D: r, D = i, c
|
|
37
|
+
return r
|
|
38
|
+
suggest.__text_signature__ = '(opts, name, /)'
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
from _collections_abc import MutableSequence
|
|
2
|
+
from typing import Final, Literal
|
|
3
|
+
MAX_STRING_SIZE: Final[int]
|
|
4
|
+
MAX_CANDIDATE_ITEMS: Final[int]
|
|
5
|
+
def lev_dist(s: str, t: str, M: int, b: MutableSequence[int], /) -> int: ...
|
|
6
|
+
def sub_cost(s: str, t: str, /) -> Literal[0, 1, 2]: ...
|
|
7
|
+
def suggest(opts: list[str], name: str, /) -> str|None: ...
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: pygensuggestions
|
|
3
|
+
Version: 0.9.0
|
|
4
|
+
Summary: Pure python implementation of the _suggestions module.
|
|
5
|
+
Author-email: Jonathan Dung <jonathandung@yahoo.com>
|
|
6
|
+
Maintainer-email: Jonathan Dung <jonathandung@yahoo.com>
|
|
7
|
+
License-Expression: MIT
|
|
8
|
+
Project-URL: Homepage, https://github.com/jonathandung/pygensuggestions
|
|
9
|
+
Project-URL: Repository, https://github.com/jonathandung/pygensuggestions.git
|
|
10
|
+
Project-URL: Issues, https://github.com/jonathandung/pygensuggestions/issues
|
|
11
|
+
Project-URL: Download, https://pypi.org/project/pygensuggestions/#files
|
|
12
|
+
Project-URL: Release Notes, https://github.com/jonathandung/pygensuggestions/releases/tag/0.9.0
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.15
|
|
22
|
+
Classifier: Programming Language :: Python :: Implementation :: CPython
|
|
23
|
+
Classifier: Operating System :: OS Independent
|
|
24
|
+
Classifier: Development Status :: 4 - Beta
|
|
25
|
+
Classifier: Intended Audience :: Developers
|
|
26
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
27
|
+
Classifier: Topic :: Software Development :: Version Control :: Git
|
|
28
|
+
Classifier: Topic :: Utilities
|
|
29
|
+
Classifier: Natural Language :: English
|
|
30
|
+
Classifier: Typing :: Typed
|
|
31
|
+
Requires-Python: >=3.9
|
|
32
|
+
Description-Content-Type: text/markdown
|
|
33
|
+
License-File: LICENSE
|
|
34
|
+
License-File: AUTHORS.md
|
|
35
|
+
Provides-Extra: dev
|
|
36
|
+
Requires-Dist: pre-commit>=4.3.0; extra == "dev"
|
|
37
|
+
Requires-Dist: mypy>=1.20.2; extra == "dev"
|
|
38
|
+
Requires-Dist: uv>=0.11.8; extra == "dev"
|
|
39
|
+
Requires-Dist: build>=1.4.4; extra == "dev"
|
|
40
|
+
Requires-Dist: twine[keyring]>=6.2.0; extra == "dev"
|
|
41
|
+
Requires-Dist: packaging>=26.2; extra == "dev"
|
|
42
|
+
Dynamic: license-file
|
|
43
|
+
|
|
44
|
+
# pygensuggestions
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
AUTHORS.md
|
|
2
|
+
LICENSE
|
|
3
|
+
README.md
|
|
4
|
+
pyproject.toml
|
|
5
|
+
pygensuggestions/__init__.py
|
|
6
|
+
pygensuggestions/__init__.pyi
|
|
7
|
+
pygensuggestions/lib.py
|
|
8
|
+
pygensuggestions/lib.pyi
|
|
9
|
+
pygensuggestions.egg-info/PKG-INFO
|
|
10
|
+
pygensuggestions.egg-info/SOURCES.txt
|
|
11
|
+
pygensuggestions.egg-info/dependency_links.txt
|
|
12
|
+
pygensuggestions.egg-info/requires.txt
|
|
13
|
+
pygensuggestions.egg-info/top_level.txt
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
pygensuggestions
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=82.0.1", "wheel>=0.47.0"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "pygensuggestions"
|
|
7
|
+
version = "0.9.0"
|
|
8
|
+
authors = [{name = "Jonathan Dung", email = "jonathandung@yahoo.com"}]
|
|
9
|
+
maintainers = [{name = "Jonathan Dung", email = "jonathandung@yahoo.com"}]
|
|
10
|
+
description = "Pure python implementation of the _suggestions module."
|
|
11
|
+
readme = "README.md"
|
|
12
|
+
requires-python = ">=3.9"
|
|
13
|
+
license = "MIT"
|
|
14
|
+
license-files = ["LICENSE", "AUTHORS.md"]
|
|
15
|
+
classifiers = ["Programming Language :: Python :: 3", "Programming Language :: Python :: 3 :: Only", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3.12", "Programming Language :: Python :: 3.13", "Programming Language :: Python :: 3.14", "Programming Language :: Python :: 3.15", "Programming Language :: Python :: Implementation :: CPython", "Operating System :: OS Independent", "Development Status :: 4 - Beta", "Intended Audience :: Developers", "Topic :: Software Development :: Libraries :: Python Modules", "Topic :: Software Development :: Version Control :: Git", "Topic :: Utilities", "Natural Language :: English", "Typing :: Typed"]
|
|
16
|
+
|
|
17
|
+
[project.urls]
|
|
18
|
+
Homepage = "https://github.com/jonathandung/pygensuggestions"
|
|
19
|
+
Repository = "https://github.com/jonathandung/pygensuggestions.git"
|
|
20
|
+
Issues = "https://github.com/jonathandung/pygensuggestions/issues"
|
|
21
|
+
Download = "https://pypi.org/project/pygensuggestions/#files"
|
|
22
|
+
"Release Notes" = "https://github.com/jonathandung/pygensuggestions/releases/tag/0.9.0"
|
|
23
|
+
|
|
24
|
+
[project.optional-dependencies]
|
|
25
|
+
dev = ["pre-commit>=4.3.0", "mypy>=1.20.2", "uv>=0.11.8", "build>=1.4.4", "twine[keyring]>=6.2.0", "packaging>=26.2"]
|
|
26
|
+
|
|
27
|
+
[tool.setuptools]
|
|
28
|
+
packages = ["pygensuggestions"]
|
|
29
|
+
|
|
30
|
+
[tool.mypy]
|
|
31
|
+
python_version = "3.9"
|
|
32
|
+
files = ["pygensuggestions/**/*.pyi"]
|
|
33
|
+
follow_imports = "skip"
|
|
34
|
+
warn_unreachable = true
|
|
35
|
+
warn_return_any = true
|
|
36
|
+
warn_redundant_casts = true
|
|
37
|
+
warn_unused_ignores = true
|
|
38
|
+
warn_incomplete_stub = true
|
|
39
|
+
disallow_untyped_defs = true
|
|
40
|
+
disallow_untyped_decorators = true
|
|
41
|
+
disallow_any_unimported = true
|
|
42
|
+
disallow_subclassing_any = true
|
|
43
|
+
disallow_any_generics = true
|
|
44
|
+
extra_checks = true
|
|
45
|
+
exclude_gitignore = true
|
|
46
|
+
|
|
47
|
+
[tool.coverage.report]
|
|
48
|
+
exclude_lines = [".*# pragma: no (cover|branch)", "if __name__ == '__main__':", "raise NotImplementedError", "def __repr__\\(self.*\\):", "\\.\\.\\."]
|
|
49
|
+
|
|
50
|
+
[tool.ruff]
|
|
51
|
+
target-version = "py39"
|
|
52
|
+
exclude = [".git", "__pycache__", "build", "dist", "venv", "env", ".venv", ".env", "*.egg-info", ".eggs", ".mypy_cache", ".pytest_cache", "docs/source/conf.py"]
|
|
53
|
+
|
|
54
|
+
[tool.ruff.lint]
|
|
55
|
+
ignore = ["ANN401", "ASYNC109", "B904", "B905", "E226", "E227", "E228", "E252", "E261", "E301", "E302", "E305", "E306", "E401", "E501", "E701", "E702", "E741", "E743", "N803", "N806", "N812", "N818", "PLC0415", "PLC2701", "PLC2801", "PLW1514", "RET502", "RET503", "RUF067", "TRY003", "TRY300", "W292"]
|
|
56
|
+
select = ["A", "ARG", "ANN", "B", "BLE001", "COM819", "C4", "C901", "E", "EM103", "ERA001", "EXE", "F", "FIX002", "FLY002", "FURB", "G", "ISC", "LOG", "N", "PERF", "PIE", "PGH004", "PL", "PYI", "RET", "RSE102", "RUF", "Q", "S", "SIM", "SLOT", "T100", "T201", "TRY", "UP", "W", "YTT"]
|
|
57
|
+
preview = true
|
|
58
|
+
typing-extensions = false
|
|
59
|
+
|
|
60
|
+
[tool.ruff.lint.per-file-ignores]
|
|
61
|
+
"**/*.py" = ["ANN", "FURB180", "PYI"]
|
|
62
|
+
"**/*.pyi" = ["PYI021", "PYI036", "PYI042"]
|
|
63
|
+
"pygensuggestions/lib.py" = ["B007"]
|
|
64
|
+
|
|
65
|
+
[tool.ruff.lint.flake8-bugbear]
|
|
66
|
+
extend-immutable-calls = ["__import__", "_functools.partial", "_operator.attrgetter", "_operator.itemgetter", "_operator.methodcaller", "pygensuggestions._internal.compat.partial", "pygensuggestions.exceptions.IgnoreErrors", "pygensuggestions.IgnoreErrors", "collections.namedtuple", "functools.partial", "globals", "itertools.count", "sys.intern", "type"]
|
|
67
|
+
|
|
68
|
+
[tool.ruff.lint.flake8-quotes]
|
|
69
|
+
inline-quotes = "single"
|
|
70
|
+
multiline-quotes = "single"
|
|
71
|
+
docstring-quotes = "single"
|
|
72
|
+
|
|
73
|
+
[tool.ruff.lint.flake8-annotations]
|
|
74
|
+
mypy-init-return = true
|
|
75
|
+
|
|
76
|
+
[tool.ruff.lint.mccabe]
|
|
77
|
+
max-complexity = 12
|
|
78
|
+
|
|
79
|
+
[tool.ruff.lint.pylint]
|
|
80
|
+
max-branches = 13
|