Skip to content

Commit 8aba4ce

Browse files
committed
Make everything in private modules public
1 parent 5568f18 commit 8aba4ce

File tree

18 files changed

+96
-96
lines changed

18 files changed

+96
-96
lines changed

.github/workflows/primer.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,13 @@ jobs:
4242
pip install -e .
4343
cd ..
4444
45-
python -m pydocstringformatter.testutils.primer.primer --prepare
46-
python -m pydocstringformatter.testutils.primer.primer --step-one
45+
python -m pydocstringformatter._testutils.primer.primer --prepare
46+
python -m pydocstringformatter._testutils.primer.primer --step-one
4747
4848
cd program_to_test
4949
git checkout $GITHUB_SHA
5050
cd ..
51-
python -m pydocstringformatter.testutils.primer.primer --step-two
51+
python -m pydocstringformatter._testutils.primer.primer --step-two
5252
- name: Upload primer diff
5353
uses: actions/upload-artifact@v3
5454
with:

pydocstringformatter/_configuration/arguments_manager.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,14 @@ def __init__(self, version: str, formatters: list[Formatter]) -> None:
3232
)
3333

3434
# Register all arguments
35-
self._register_arguments(version)
36-
formatter_options._register_arguments_formatters(
35+
self.register_arguments(version)
36+
formatter_options.register_arguments_formatters(
3737
self.default_formatters_group,
3838
self.optional_formatters_group,
3939
self.formatters,
4040
)
4141

42-
def _register_arguments(self, version: str) -> None:
42+
def register_arguments(self, version: str) -> None:
4343
"""Register all standard arguments on the parser."""
4444
self.parser.add_argument(
4545
"files", nargs="*", type=str, help="The directory or files to format."
@@ -128,9 +128,9 @@ def parse_options(
128128
1. configuration files, 2. command line arguments.
129129
"""
130130
# pylint: disable=protected-access
131-
toml_parsing._parse_toml_file(self.parser, self.namespace)
131+
toml_parsing.parse_toml_file(self.parser, self.namespace)
132132

133-
command_line_parsing._parse_command_line_arguments(
133+
command_line_parsing.parse_command_line_arguments(
134134
self.parser, self.namespace, argv
135135
)
136136

pydocstringformatter/_configuration/command_line_parsing.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import argparse
44

55

6-
def _parse_command_line_arguments(
6+
def parse_command_line_arguments(
77
parser: argparse.ArgumentParser, namespace: argparse.Namespace, args: list[str]
88
) -> None:
99
"""Parse all arguments on the provided argument parser."""

pydocstringformatter/_configuration/formatter_options.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from pydocstringformatter._formatting.base import Formatter
99

1010

11-
def _register_arguments_formatters(
11+
def register_arguments_formatters(
1212
default_arg_group: argparse._ArgumentGroup,
1313
optional_arg_group: argparse._ArgumentGroup,
1414
formatters: list[Formatter],

pydocstringformatter/_configuration/toml_parsing.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
OPTIONS_TYPES: Final = {"write": "store_true", "exclude": "store"}
1212

1313

14-
def _get_toml_file() -> dict[str, Any] | None:
14+
def get_toml_file() -> dict[str, Any] | None:
1515
"""See if there is a pyproject.toml and extract the correct section if it exists."""
1616
if os.path.isfile("pyproject.toml"):
1717
with open("pyproject.toml", "rb") as file:
@@ -26,7 +26,7 @@ def _get_toml_file() -> dict[str, Any] | None:
2626
return None
2727

2828

29-
def _parse_toml_option(opt: str, value: Any) -> list[str]:
29+
def parse_toml_option(opt: str, value: Any) -> list[str]:
3030
"""Parse an options value in the correct argument type for argparse."""
3131
try:
3232
action = OPTIONS_TYPES[opt]
@@ -42,14 +42,14 @@ def _parse_toml_option(opt: str, value: Any) -> list[str]:
4242
return [] # pragma: no cover
4343

4444

45-
def _parse_toml_file(
45+
def parse_toml_file(
4646
parser: argparse.ArgumentParser, namespace: argparse.Namespace
4747
) -> None:
4848
"""Get and parse the relevant section form a pyproject.toml file."""
49-
if toml_sect := _get_toml_file():
49+
if toml_sect := get_toml_file():
5050
arguments: list[str] = []
5151

5252
for key, value in toml_sect.items():
53-
arguments += _parse_toml_option(key, value)
53+
arguments += parse_toml_option(key, value)
5454

5555
parser.parse_args(arguments, namespace)

pydocstringformatter/_configuration/validators.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from typing import Final, List
55

66

7-
def _comma_separated_list_validator(value: str | list[str]) -> list[str]:
7+
def comma_separated_list_validator(value: str | list[str]) -> list[str]:
88
"""Validate a comma separated list."""
99
if isinstance(value, list):
1010
return value
@@ -13,5 +13,5 @@ def _comma_separated_list_validator(value: str | list[str]) -> list[str]:
1313

1414
ValidatedTypes = List[str]
1515
VALIDATORS: Final[dict[str, Callable[[str], ValidatedTypes]]] = {
16-
"csv": _comma_separated_list_validator
16+
"csv": comma_separated_list_validator
1717
}

pydocstringformatter/_formatting/base.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,13 @@ class StringFormatter(Formatter):
4848
"""Base class for formatter that only modifies the string content."""
4949

5050
@abc.abstractmethod
51-
def _treat_string(self, tokeninfo: tokenize.TokenInfo, indent_length: int) -> str:
51+
def treat_string(self, tokeninfo: tokenize.TokenInfo, indent_length: int) -> str:
5252
"""Return a modified string."""
5353

5454
def treat_token(self, tokeninfo: tokenize.TokenInfo) -> tokenize.TokenInfo:
5555
return tokenize.TokenInfo(
5656
tokeninfo.type,
57-
self._treat_string(tokeninfo, tokeninfo.start[1]),
57+
self.treat_string(tokeninfo, tokeninfo.start[1]),
5858
tokeninfo.start,
5959
tokeninfo.end,
6060
tokeninfo.line,
@@ -68,7 +68,7 @@ class StringAndQuotesFormatter(Formatter):
6868
"""Pattern to match against opening quotes."""
6969

7070
@abc.abstractmethod
71-
def _treat_string(
71+
def treat_string(
7272
self,
7373
tokeninfo: tokenize.TokenInfo,
7474
indent_length: int,
@@ -88,7 +88,7 @@ def treat_token(self, tokeninfo: tokenize.TokenInfo) -> tokenize.TokenInfo:
8888

8989
return tokenize.TokenInfo(
9090
tokeninfo.type,
91-
self._treat_string(
91+
self.treat_string(
9292
tokeninfo,
9393
tokeninfo.start[1],
9494
quotes,
@@ -104,7 +104,7 @@ class SummaryAndDescriptionFormatter(StringAndQuotesFormatter):
104104
"""Base class for formatter that modifies the summary and description."""
105105

106106
@abc.abstractmethod
107-
def _treat_summary(
107+
def treat_summary(
108108
self,
109109
summary: str,
110110
indent_length: int,
@@ -114,12 +114,12 @@ def _treat_summary(
114114
"""Return a modified summary."""
115115

116116
@abc.abstractmethod
117-
def _treat_description(self, description: str, indent_length: int) -> str:
117+
def treat_description(self, description: str, indent_length: int) -> str:
118118
"""Return a modified description."""
119119

120120
@staticmethod
121121
@functools.lru_cache(maxsize=None)
122-
def _separate_summary_and_description(
122+
def separate_summary_and_description(
123123
docstring: str, indent_length: int, quotes_length: Literal[1, 3]
124124
) -> tuple[str, str, str | None]:
125125
"""Split the summary and description and handle quotes and indentation."""
@@ -153,26 +153,26 @@ def _separate_summary_and_description(
153153
summary = summary[1 + indent_length :]
154154
return prefix, summary, description
155155

156-
def _treat_string(
156+
def treat_string(
157157
self,
158158
tokeninfo: tokenize.TokenInfo,
159159
indent_length: int,
160160
quotes: str,
161161
quotes_length: Literal[1, 3],
162162
) -> str:
163-
prefix, summary, description = self._separate_summary_and_description(
163+
prefix, summary, description = self.separate_summary_and_description(
164164
tokeninfo.string,
165165
indent_length,
166166
quotes_length,
167167
)
168168

169-
new_summary = self._treat_summary(
169+
new_summary = self.treat_summary(
170170
summary, indent_length, quotes_length, bool(description)
171171
)
172172
docstring = f"{quotes}{prefix}{new_summary}"
173173

174174
if description:
175-
new_description = self._treat_description(description, indent_length)
175+
new_description = self.treat_description(description, indent_length)
176176
docstring += f"\n\n{new_description}"
177177

178178
# Determine whether ending quotes were initially on same or new line
@@ -185,7 +185,7 @@ class SummaryFormatter(SummaryAndDescriptionFormatter):
185185
"""Base class for formatter that only modifies the summary of a docstring."""
186186

187187
@abc.abstractmethod
188-
def _treat_summary(
188+
def treat_summary(
189189
self,
190190
summary: str,
191191
indent_length: int,
@@ -194,5 +194,5 @@ def _treat_summary(
194194
) -> str:
195195
"""Return a modified summary."""
196196

197-
def _treat_description(self, description: str, indent_length: int) -> str:
197+
def treat_description(self, description: str, indent_length: int) -> str:
198198
return description

pydocstringformatter/_formatting/formatter.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class BeginningQuotesFormatter(StringFormatter):
2828
)
2929
"""Regex pattern to match against a potential single line docstring."""
3030

31-
def _treat_string(self, tokeninfo: tokenize.TokenInfo, _: int) -> str:
31+
def treat_string(self, tokeninfo: tokenize.TokenInfo, _: int) -> str:
3232
new_string = tokeninfo.string
3333
if new_string[3] == "\n":
3434
if (
@@ -46,7 +46,7 @@ class CapitalizeFirstLetterFormatter(StringFormatter):
4646
name = "capitalize-first-letter"
4747
first_letter_re = re.compile(r"""['"]{1,3}\s*(\w)""", re.DOTALL)
4848

49-
def _treat_string(self, tokeninfo: tokenize.TokenInfo, _: int) -> str:
49+
def treat_string(self, tokeninfo: tokenize.TokenInfo, _: int) -> str:
5050
new_string = None
5151
if match := self.first_letter_re.match(tokeninfo.string):
5252
first_letter = match.end() - 1
@@ -64,7 +64,7 @@ class LineWrapperFormatter(SummaryFormatter):
6464
name = "linewrap-full-docstring"
6565
optional = True
6666

67-
def _treat_summary(
67+
def treat_summary(
6868
self,
6969
summary: str,
7070
indent_length: int,
@@ -120,7 +120,7 @@ class ClosingQuotesFormatter(StringFormatter):
120120

121121
name = "closing-quotes"
122122

123-
def _treat_string(self, tokeninfo: tokenize.TokenInfo, _: int) -> str:
123+
def treat_string(self, tokeninfo: tokenize.TokenInfo, _: int) -> str:
124124
"""Fix the position of end quotes for multi-line docstrings."""
125125
new_string = tokeninfo.string
126126
if "\n" not in new_string:
@@ -144,7 +144,7 @@ class FinalPeriodFormatter(SummaryFormatter):
144144
name = "final-period"
145145
END_OF_SENTENCE_PUNCTUATION = {".", "?", "!", "‽", ":", ";"}
146146

147-
def _treat_summary(
147+
def treat_summary(
148148
self,
149149
summary: str,
150150
indent_length: int,
@@ -180,7 +180,7 @@ class SplitSummaryAndDocstringFormatter(SummaryFormatter):
180180
"""Pattern to match against an end of sentence period."""
181181

182182
# pylint: disable-next=too-many-branches
183-
def _treat_summary(
183+
def treat_summary(
184184
self,
185185
summary: str,
186186
indent_length: int,
@@ -230,7 +230,7 @@ class StripWhitespacesFormatter(StringAndQuotesFormatter):
230230

231231
name = "strip-whitespaces"
232232

233-
def _treat_string(
233+
def treat_string(
234234
self,
235235
tokeninfo: tokenize.TokenInfo,
236236
indent_length: int,
@@ -275,7 +275,7 @@ class QuotesTypeFormatter(StringAndQuotesFormatter):
275275

276276
name = "quotes-type"
277277

278-
def _treat_string(
278+
def treat_string(
279279
self,
280280
tokeninfo: tokenize.TokenInfo,
281281
_: int,

pydocstringformatter/_testutils/primer/packages.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212

1313
@dataclass
14-
class _PackageToPrime:
14+
class PackageToPrime:
1515
"""Represents data about a package to be tested during primer tests."""
1616

1717
url: str
@@ -58,13 +58,13 @@ def lazy_clone(self) -> None:
5858

5959

6060
PACKAGES = {
61-
"pylint": _PackageToPrime(
61+
"pylint": PackageToPrime(
6262
"https://github.com/PyCQA/pylint",
6363
"main",
6464
["pylint"],
6565
["--max-summary-lines=2"],
6666
),
67-
"pydocstringformatter": _PackageToPrime(
67+
"pydocstringformatter": PackageToPrime(
6868
"https://github.com/DanielNoord/pydocstringformatter",
6969
"main",
7070
["pydocstringformatter"],

pydocstringformatter/_testutils/primer/primer.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
from pathlib import Path
66

77
from pydocstringformatter._testutils.primer.const import DIFF_OUTPUT
8-
from pydocstringformatter._testutils.primer.packages import PACKAGES, _PackageToPrime
8+
from pydocstringformatter._testutils.primer.packages import PACKAGES, PackageToPrime
99

1010

11-
def _fix_diff(output: str, package: _PackageToPrime) -> str:
11+
def fix_diff(output: str, package: PackageToPrime) -> str:
1212
"""Make the diff more readable and useful."""
1313
new_output: list[str] = []
1414

@@ -28,7 +28,7 @@ def _fix_diff(output: str, package: _PackageToPrime) -> str:
2828
return "\n".join(new_output)
2929

3030

31-
def _run_prepare() -> None:
31+
def run_prepare() -> None:
3232
"""Prepare everything for the primer to be run.
3333
3434
This clones all packages that need to be 'primed' and
@@ -40,7 +40,7 @@ def _run_prepare() -> None:
4040
print("## Preparation of primer successful!")
4141

4242

43-
def _run_step_one() -> None:
43+
def run_step_one() -> None:
4444
"""Run program over all packages in write mode.
4545
4646
Runs the program in write mode over all packages that need
@@ -61,7 +61,7 @@ def _run_step_one() -> None:
6161
print("## Step one of primer successful!")
6262

6363

64-
def _run_step_two() -> None:
64+
def run_step_two() -> None:
6565
"""Run program over all packages and store the diff.
6666
6767
This reiterates over all packages that need to be 'primed',
@@ -79,7 +79,7 @@ def _run_step_two() -> None:
7979
text=True,
8080
check=False,
8181
)
82-
output[name] = _fix_diff(process.stdout, package)
82+
output[name] = fix_diff(process.stdout, package)
8383

8484
final_output = ""
8585
for name, string in output.items():
@@ -93,17 +93,17 @@ def _run_step_two() -> None:
9393
print("## Step two of primer successful!")
9494

9595

96-
def _run_primer() -> None:
96+
def run_primer() -> None:
9797
"""Run the primer test."""
9898
args = sys.argv[1:]
9999

100100
if "--prepare" in args:
101-
_run_prepare()
101+
run_prepare()
102102
elif "--step-one" in args:
103-
_run_step_one()
103+
run_step_one()
104104
elif "--step-two" in args:
105-
_run_step_two()
105+
run_step_two()
106106

107107

108108
if __name__ == "__main__":
109-
_run_primer()
109+
run_primer()

0 commit comments

Comments
 (0)