Skip to content

Commit 2b48a80

Browse files
committed
Eliminate unnecessary variables
1 parent 792a2b4 commit 2b48a80

File tree

2 files changed

+9
-14
lines changed

2 files changed

+9
-14
lines changed

src/towncrier/build.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,6 @@ def __main(
119119

120120
click.echo("Finding news fragments...", err=to_err)
121121

122-
definitions = config.types
123-
124122
if config.directory:
125123
fragment_base_directory = os.path.abspath(config.directory)
126124
fragment_directory = None
@@ -134,13 +132,13 @@ def __main(
134132
fragment_base_directory,
135133
config.sections,
136134
fragment_directory,
137-
definitions,
135+
config.types,
138136
config.orphan_prefix,
139137
)
140138

141139
click.echo("Rendering news fragments...", err=to_err)
142140
fragments = split_fragments(
143-
fragment_contents, definitions, all_bullets=config.all_bullets
141+
fragment_contents, config.types, all_bullets=config.all_bullets
144142
)
145143

146144
if project_version is None:
@@ -188,7 +186,7 @@ def __main(
188186
template,
189187
config.issue_format,
190188
fragments,
191-
definitions,
189+
config.types,
192190
config.underlines[1:],
193191
config.wrap,
194192
{"name": project_name, "version": project_version, "date": project_date},
@@ -217,7 +215,6 @@ def __main(
217215
click.echo(content)
218216
else:
219217
click.echo("Writing to newsfile...", err=to_err)
220-
start_string = config.start_string
221218
news_file = config.filename
222219

223220
if config.single_file is False:
@@ -230,7 +227,7 @@ def __main(
230227
append_to_newsfile(
231228
base_directory,
232229
news_file,
233-
start_string,
230+
config.start_string,
234231
top_line,
235232
content,
236233
single_file=config.single_file,

src/towncrier/create.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -81,19 +81,17 @@ def __main(
8181
"""
8282
base_directory, config = load_config_from_options(directory, config_path)
8383

84-
definitions = config.types or {}
85-
orphan_prefix = config.orphan_prefix
86-
if orphan_prefix and filename.startswith(f"{orphan_prefix}."):
84+
if config.orphan_prefix and filename.startswith(f"{config.orphan_prefix}."):
8785
# Append a random hex string to the orphan news fragment base name.
88-
filename = f"{orphan_prefix}{os.urandom(4).hex()}{filename[1:]}"
86+
filename = f"{config.orphan_prefix}{os.urandom(4).hex()}{filename[1:]}"
8987
if len(filename.split(".")) < 2 or (
90-
filename.split(".")[-1] not in definitions
91-
and filename.split(".")[-2] not in definitions
88+
filename.split(".")[-1] not in config.types
89+
and filename.split(".")[-2] not in config.types
9290
):
9391
raise click.BadParameter(
9492
"Expected filename '{}' to be of format '{{name}}.{{type}}', "
9593
"where '{{name}}' is an arbitrary slug and '{{type}}' is "
96-
"one of: {}".format(filename, ", ".join(definitions))
94+
"one of: {}".format(filename, ", ".join(config.types))
9795
)
9896

9997
if config.directory:

0 commit comments

Comments
 (0)