Skip to content

Commit 3eccbec

Browse files
authored
Enabled 28 new Ruff linting rulesets
Large code refactor to enable a bunch of additional ruff rulesets See PR 1421 for full details: #1421
1 parent a61513e commit 3eccbec

File tree

113 files changed

+3245
-4059
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

113 files changed

+3245
-4059
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
- Breaking Change
44
- `cmd2` 2.6 supports Python 3.9+ (removed support for Python 3.8)
5+
- Renamed methods in `cmd2.ansi.Cursor` to make it clear they are intended for internal use only as was documented
56
- Enhancements
67
- Add support for Python 3.14
78

Makefile

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,18 @@ check: ## Run code quality tools.
1313
@echo "🚀 Static type checking: Running mypy"
1414
@uv run mypy
1515

16+
.PHONY: format
17+
format: ## Perform ruff formatting
18+
@uv run ruff format
19+
20+
.PHONY: lint
21+
lint: ## Perform ruff linting
22+
@uv run ruff check --fix
23+
24+
.PHONY: typecheck
25+
typecheck: ## Perform type checking
26+
@uv run mypy
27+
1628
.PHONY: test
1729
test: ## Test the code with pytest.
1830
@echo "🚀 Testing code: Running pytest"

cmd2/__init__.py

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,21 @@
1-
#
2-
# -*- coding: utf-8 -*-
3-
# flake8: noqa F401
41
"""This simply imports certain things for backwards compatibility."""
52

6-
import sys
7-
3+
import argparse
84
import importlib.metadata as importlib_metadata
5+
import sys
96

107
try:
118
__version__ = importlib_metadata.version(__name__)
129
except importlib_metadata.PackageNotFoundError: # pragma: no cover
1310
# package is not installed
1411
pass
1512

16-
from typing import List
17-
1813
from .ansi import (
19-
Cursor,
2014
Bg,
21-
Fg,
15+
Cursor,
2216
EightBitBg,
2317
EightBitFg,
18+
Fg,
2419
RgbBg,
2520
RgbFg,
2621
TextStyle,
@@ -36,34 +31,30 @@
3631

3732
# Check if user has defined a module that sets a custom value for argparse_custom.DEFAULT_ARGUMENT_PARSER.
3833
# Do this before loading cmd2.Cmd class so its commands use the custom parser.
39-
import argparse
40-
4134
cmd2_parser_module = getattr(argparse, 'cmd2_parser_module', None)
4235
if cmd2_parser_module is not None:
4336
import importlib
4437

4538
importlib.import_module(cmd2_parser_module)
4639

40+
from . import plugin
4741
from .argparse_completer import set_default_ap_completer_type
48-
4942
from .cmd2 import Cmd
5043
from .command_definition import CommandSet, with_default_category
5144
from .constants import COMMAND_NAME, DEFAULT_SHORTCUTS
52-
from .decorators import with_argument_list, with_argparser, with_category, as_subcommand_to
45+
from .decorators import as_subcommand_to, with_argparser, with_argument_list, with_category
5346
from .exceptions import (
5447
Cmd2ArgparseError,
5548
CommandSetRegistrationError,
5649
CompletionError,
5750
PassThroughException,
5851
SkipPostcommandHooks,
5952
)
60-
from . import plugin
6153
from .parsing import Statement
6254
from .py_bridge import CommandResult
63-
from .utils import categorize, CompletionMode, CustomCompletionSettings, Settable
64-
55+
from .utils import CompletionMode, CustomCompletionSettings, Settable, categorize
6556

66-
__all__: List[str] = [
57+
__all__: list[str] = [
6758
'COMMAND_NAME',
6859
'DEFAULT_SHORTCUTS',
6960
# ANSI Exports

0 commit comments

Comments
 (0)