Skip to content

Commit a330f77

Browse files
committed
Migrate to a modern Python project where all configuration is in pyproject.toml
This includes the following: - Remove setup.cfg - Remove setup.py - Update pyproject.toml with project and tool settings - Add build module to Pipfile for building using pyproject.toml - Add ruff fast linter/formatter to Pipfile - Some very initial minor fixes based on ruff - Update invoke tasks in tasks.py to not use setup.py
1 parent 3062aaa commit a330f77

File tree

10 files changed

+236
-176
lines changed

10 files changed

+236
-176
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,6 @@ Pipfile.lock
4343

4444
# pyenv version file
4545
.python-version
46+
47+
# uv
48+
uv.lock

Pipfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,13 @@ wcwidth = ">=0.1.7"
1010

1111
[dev-packages]
1212
black = "*"
13+
build = "*"
1314
cmd2 = {editable = true,path = "."}
1415
cmd2_ext_test = {editable = true,path = "plugins/ext_test"}
1516
codecov = "*"
1617
doc8 = "*"
1718
flake8 = "*"
19+
Flake8-pyproject = "*"
1820
gnureadline = {version = "*",sys_platform = "== 'darwin'"}
1921
invoke = "*"
2022
ipython = "*"
@@ -24,6 +26,7 @@ pyreadline3 = {version = ">=3.4",sys_platform = "== 'win32'"}
2426
pytest = "*"
2527
pytest-cov = "*"
2628
pytest-mock = "*"
29+
ruff = "*"
2730
sphinx = "*"
2831
sphinx-autobuild = "*"
2932
sphinx-rtd-theme = "*"

cmd2/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,4 +106,5 @@
106106
'CompletionMode',
107107
'CustomCompletionSettings',
108108
'Settable',
109+
'PassThroughException',
109110
]

cmd2/argparse_completer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ def _looks_like_flag(token: str, parser: argparse.ArgumentParser) -> bool:
9292
return False
9393

9494
# Flags have to start with a prefix character
95-
if not token[0] in parser.prefix_chars:
95+
if token[0] not in parser.prefix_chars:
9696
return False
9797

9898
# If it looks like a negative number, it is not a flag unless there are negative-number-like flags

cmd2/cmd2.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5537,7 +5537,7 @@ def cmdloop(self, intro: Optional[str] = None) -> int: # type: ignore[override]
55375537
"""
55385538
# cmdloop() expects to be run in the main thread to support extensive use of KeyboardInterrupts throughout the
55395539
# other built-in functions. You are free to override cmdloop, but much of cmd2's features will be limited.
5540-
if not threading.current_thread() is threading.main_thread():
5540+
if threading.current_thread() is not threading.main_thread():
55415541
raise RuntimeError("cmdloop must be run in the main thread")
55425542

55435543
# Register signal handlers

pyproject.toml

Lines changed: 212 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,87 @@
11
[build-system]
2-
requires = ["setuptools>=42", "wheel", "setuptools_scm[toml]>=3.4"]
2+
requires = [
3+
"setuptools>=64",
4+
"setuptools-scm>=8",
5+
]
6+
build-backend = "setuptools.build_meta"
7+
8+
[project]
9+
name = "cmd2"
10+
description = "Quickly build feature-rich and user-friendly interactive command line applications in Python"
11+
readme = "README.md"
12+
license.file = "LICENSE"
13+
authors = [ { name = "cmd2 Contributors" } ]
14+
requires-python = ">=3.8"
15+
classifiers = [
16+
"Development Status :: 5 - Production/Stable",
17+
"Environment :: Console",
18+
"Intended Audience :: Developers",
19+
"Intended Audience :: System Administrators",
20+
"License :: OSI Approved :: MIT License",
21+
"Operating System :: MacOS",
22+
"Operating System :: Microsoft :: Windows",
23+
"Operating System :: POSIX",
24+
"Operating System :: Unix",
25+
"Programming Language :: Python",
26+
"Programming Language :: Python :: 3 :: Only",
27+
"Programming Language :: Python :: 3.8",
28+
"Programming Language :: Python :: 3.9",
29+
"Programming Language :: Python :: 3.10",
30+
"Programming Language :: Python :: 3.11",
31+
"Programming Language :: Python :: 3.12",
32+
"Programming Language :: Python :: Implementation :: CPython",
33+
"Topic :: Software Development :: Libraries",
34+
]
35+
keywords = [
36+
"cmd",
37+
"command",
38+
"console",
39+
"prompt",
40+
]
41+
dynamic = [
42+
"version",
43+
]
44+
dependencies = [
45+
"pyperclip",
46+
"wcwidth",
47+
'gnureadline ; platform_system == "Darwin"',
48+
'pyreadline3 ; platform_system == "Windows"',
49+
]
50+
[project.optional-dependencies]
51+
dev = [
52+
"codecov",
53+
"doc8",
54+
"flake8",
55+
"Flake8-pyproject",
56+
"black",
57+
"isort",
58+
"invoke",
59+
"mypy",
60+
"nox",
61+
"pytest",
62+
"pytest-cov",
63+
"pytest-mock",
64+
"sphinx",
65+
"sphinx-rtd-theme",
66+
"sphinx-autobuild",
67+
"twine",
68+
]
69+
test = [
70+
"codecov",
71+
"coverage",
72+
"pytest",
73+
"pytest-cov",
74+
"pytest-mock",
75+
]
76+
validate = [
77+
"flake8",
78+
"Flake8-pyproject",
79+
"mypy",
80+
"types-setuptools",
81+
]
82+
[project.urls]
83+
documentation = "https://cmd2.readthedocs.io/"
84+
repository = "https://github.com/python-cmd2/cmd2"
385

486
[tool.black]
587
skip-string-normalization = true
@@ -25,3 +107,132 @@ exclude = '''
25107
| htmlcov
26108
)/
27109
'''
110+
111+
[tool.doc8]
112+
ignore-path = [
113+
"__pycache__",
114+
"*.egg",
115+
".git",
116+
".idea",
117+
".nox",
118+
".pytest_cache",
119+
".tox",
120+
".venv",
121+
".vscode",
122+
"build",
123+
"cmd2",
124+
"cmd2.egg-info",
125+
"dist",
126+
"docs/_build",
127+
"examples",
128+
"htmlcov",
129+
"plugins",
130+
"tests",
131+
]
132+
max-line-length = 120
133+
verbose = 0
134+
135+
[tool.flake8]
136+
count = true
137+
ignore = ['E203', 'E704', 'W503']
138+
max-complexity = 26
139+
max-line-length = 127
140+
per-file-ignores = [
141+
'__init__.py:F401',
142+
]
143+
show-source = true
144+
statistics = true
145+
exclude = [
146+
"__pycache__",
147+
".eggs",
148+
"*.eggs",
149+
".git",
150+
".idea",
151+
".nox",
152+
".pytest_cache",
153+
".tox",
154+
".venv",
155+
".vscode",
156+
"build",
157+
"dist",
158+
"htmlcov",
159+
]
160+
161+
[tool.isort]
162+
profile = "black"
163+
force_grid_wrap = 0
164+
include_trailing_comma = true
165+
line_length = 1
166+
multi_line_output = 3
167+
use_parentheses = true
168+
skip = [
169+
"__pycache",
170+
".eggs",
171+
".git",
172+
".idea",
173+
".nox",
174+
".tox",
175+
".venv",
176+
".vscode",
177+
"cmd2/__init__.py",
178+
"build",
179+
"dist",
180+
"htmlcov",
181+
]
182+
183+
[tool.mypy]
184+
disallow_incomplete_defs = true
185+
disallow_untyped_calls = true
186+
disallow_untyped_defs = true
187+
exclude = [
188+
"examples",
189+
"plugins",
190+
]
191+
strict = true
192+
show_column_numbers = true
193+
show_error_codes = true
194+
show_error_context = true
195+
warn_redundant_casts = true
196+
warn_return_any = true
197+
warn_unused_ignores = false
198+
warn_unreachable = true
199+
200+
[tool.pytest.ini_options]
201+
minversion = "8"
202+
addopts = "--cov=cmd2 --cov-append --cov-report=term --cov-report=html"
203+
testpaths = [
204+
"tests",
205+
]
206+
207+
[tool.ruff]
208+
src = ["cmd2"]
209+
fix = true
210+
line-length = 127
211+
lint.preview = true
212+
exclude=[
213+
".git",
214+
"__pycache__",
215+
"dist",
216+
"docs/_build",
217+
"build",
218+
]
219+
220+
[tool.ruff.format]
221+
docstring-code-format = true
222+
#quote-style = "double"
223+
224+
[tool.ruff.lint.isort]
225+
force-single-line = true
226+
from-first = false
227+
lines-between-types = 1
228+
order-by-type = true
229+
230+
[tool.setuptools.package-data]
231+
"cmd2" = ["py.typed"]
232+
233+
[tool.setuptools.packages.find]
234+
where = ["cmd2"]
235+
namespaces = false
236+
237+
[tool.setuptools_scm]
238+

setup.cfg

Lines changed: 0 additions & 57 deletions
This file was deleted.

0 commit comments

Comments
 (0)