Skip to content

Commit 926d9f0

Browse files
authored
refactor: split long functions into smaller functions (#318)
* refactor: split long functions/methods into smaller functions * Use TokenInfo objects directly instead of tuples with attributes from TokenInfo objects. * Move non-formatting functions to other modules. * Add functions to determine number of blank lines after docstring for modules, classes, functions, and attributes. * Add function to update the token indices after removing unnecessary blank lines. * Add method to insert appropriate number of blank lines after each type of docstring. * refactor: add new module with functions for classifying docstring types * refactor: add new module with constant values * refactor: add new module with functions for detecting various types of patterns * refactor: add new module with functions for wrapping various elements * refactor: move string manipulation functions from syntax module * refactor: add function to have field lists take precedence over URL strings * chore: add copyright info for new maintainer * refactor: rename attributes * chore: add integration test mark * test: update and add tests for format module * test: update and add tests for encoding module * test: update and add tests for string module * test: update and add tests for utility module * test: update and add tests for configuration module * test: update and add tests for docformatter end-to-end * test: add tests for classify module * test: add tests for classify module * test: add tests for wrapper package * test: update end-to-end tests * test: update expected value for all Python versions
1 parent fe1a85f commit 926d9f0

File tree

86 files changed

+10038
-8730
lines changed

Some content is hidden

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

86 files changed

+10038
-8730
lines changed

poetry.lock

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

pyproject.toml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ coverage = {extras = ["toml"], version = "^6.4.0"}
4545
mock = "^4.0.0"
4646
pytest = "^7.1.0"
4747
pytest-cov = "^4.0.0"
48+
pytest-order = "^1.3.0"
4849

4950
[tool.poetry.group.linting.dependencies]
5051
autopep8 = "^2.0.0"
@@ -107,6 +108,7 @@ convention = "pep257"
107108
[tool.pytest.ini_options]
108109
markers = [
109110
"unit: mark the test as a unit test.",
111+
"integration: mark the test as an integration test.",
110112
"system: mark the test as a system test.",
111113
]
112114

@@ -216,6 +218,7 @@ deps =
216218
mock
217219
pytest
218220
pytest-cov
221+
pytest-order
219222
tomli
220223
untokenize
221224
setenv =
@@ -230,6 +233,13 @@ commands =
230233
--cov-config={toxinidir}/pyproject.toml \
231234
--cov-branch \
232235
{toxinidir}/tests/
236+
pytest -s -x -c {toxinidir}/pyproject.toml \
237+
-m integration \
238+
--cache-clear \
239+
--cov=docformatter \
240+
--cov-config={toxinidir}/pyproject.toml \
241+
--cov-branch \
242+
{toxinidir}/tests/
233243
pytest -s -x -c {toxinidir}/pyproject.toml \
234244
-m system \
235245
--cache-clear \

src/docformatter/__init__.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
#!/usr/bin/env python
22
#
3+
# docformatter.__init__.py is part of the docformatter project
4+
#
35
# Copyright (C) 2012-2023 Steven Myint
6+
# Copyright (C) 2023-2025 Doyle "weibullguy" Rowland
47
#
58
# Permission is hereby granted, free of charge, to any person obtaining
69
# a copy of this software and associated documentation files (the
@@ -23,15 +26,19 @@
2326
# SOFTWARE.
2427
"""This is the docformatter package."""
2528

29+
2630
__all__ = ["__version__"]
2731

2832
# docformatter Local Imports
2933
from .__pkginfo__ import __version__
34+
from .classify import * # noqa F403
35+
from .format import FormatResult # noqa F403
36+
from .format import Formatter # noqa F401
37+
from .patterns import * # noqa F403
3038
from .strings import * # noqa F403
31-
from .syntax import * # noqa F403
3239
from .util import * # noqa F403
40+
from .wrappers import * # noqa F403
3341

3442
# Have isort skip these they require the functions above.
3543
from .configuration import Configurater # isort: skip # noqa F401
3644
from .encode import Encoder # isort: skip # noqa F401
37-
from .format import Formatter, FormatResult # isort: skip # noqa F401

src/docformatter/__main__.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
#!/usr/bin/env python
22
#
3+
# docformatter.__main__.py is part of the docformatter project
4+
#
35
# Copyright (C) 2012-2023 Steven Myint
6+
# Copyright (C) 2023-2025 Doyle "weibullguy" Rowland
47
#
58
# Permission is hereby granted, free of charge, to any person obtaining
69
# a copy of this software and associated documentation files (the
@@ -135,7 +138,7 @@ def _main(argv, standard_out, standard_error, standard_in):
135138

136139

137140
def main():
138-
"""Run main entry point."""
141+
"""Run the main entry point."""
139142
# SIGPIPE is not available on Windows.
140143
with contextlib.suppress(AttributeError):
141144
# Exit on broken pipe.

src/docformatter/__pkginfo__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
#!/usr/bin/env python
22
#
3+
# docformatter.patterns.__pkginfo__.py is part of the docformatter project
4+
#
35
# Copyright (C) 2012-2023 Steven Myint
6+
# Copyright (C) 2023-2025 Doyle "weibullguy" Rowlans
47
#
58
# Permission is hereby granted, free of charge, to any person obtaining
69
# a copy of this software and associated documentation files (the
@@ -23,4 +26,5 @@
2326
# SOFTWARE.
2427
"""Package information for docformatter."""
2528

29+
2630
__version__ = "1.7.7"

0 commit comments

Comments
 (0)