diff --git a/.flake8 b/.flake8 deleted file mode 100644 index 3907f28c..00000000 --- a/.flake8 +++ /dev/null @@ -1,6 +0,0 @@ -[flake8] -# Allow for longer test strings. Code is formatted to 88 columns by Black. -max-line-length = 99 -extend-ignore = - # Conflict between flake8 & black about whitespace in slices. - E203 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 3b6f4392..700a838c 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -3,27 +3,13 @@ ci: autoupdate_schedule: monthly repos: - - repo: https://github.com/psf/black-pre-commit-mirror - rev: 25.12.0 - hooks: - - id: black - - - repo: https://github.com/asottile/pyupgrade - rev: v3.21.2 - hooks: - - id: pyupgrade - args: [--py39-plus] - - - repo: https://github.com/PyCQA/isort - rev: 7.0.0 - hooks: - - id: isort - additional_dependencies: [toml] - - repo: https://github.com/PyCQA/flake8 - rev: 7.3.0 + - repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.15.15 hooks: - - id: flake8 + - id: ruff-check + args: [--fix, --exit-non-zero-on-fix] + - id: ruff-format - repo: https://github.com/pre-commit/pre-commit-hooks rev: v6.0.0 diff --git a/bin/towncrier b/bin/towncrier index a5604922..30c43f33 100755 --- a/bin/towncrier +++ b/bin/towncrier @@ -4,11 +4,9 @@ import os.path import sys - srcdir = os.path.join(os.path.dirname(__file__), "..", "src") sys.path.insert(0, srcdir) import towncrier - towncrier._main() diff --git a/docs/conf.py b/docs/conf.py index f98d50c8..99be2bdc 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -55,10 +55,7 @@ # General information about the project. _today = date.today() project = "Towncrier" -copyright = "{}, Towncrier contributors. Ver {}".format( - _today.year, - towncrier_version, -) +copyright = f"{_today.year}, Towncrier contributors. Ver {towncrier_version}" author = "Amber Brown" # The version info for the project you're documenting, acts as replacement for diff --git a/noxfile.py b/noxfile.py index 494085c7..1d0bab80 100644 --- a/noxfile.py +++ b/noxfile.py @@ -74,7 +74,6 @@ def docs(session: nox.Session) -> None: session.install(".[dev]") session.run( - # fmt: off "python", "-m", "sphinx", "-T", "-E", "-W", "--keep-going", @@ -83,8 +82,7 @@ def docs(session: nox.Session) -> None: "-D", "language=en", "docs", "docs/_build/html", - # fmt: on - ) + ) # fmt: skip @nox.session diff --git a/pyproject.toml b/pyproject.toml index f39dd740..d45306a2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -107,36 +107,25 @@ exclude = [ showcontent = false -[tool.black] -exclude = ''' - -( - /( - \.eggs # exclude a few common directories in the - | \.git # root of the project - | \.nox - | \.venv - | \.env - | env - | _build - | _trial_temp.* - | build - | dist - | debian - )/ -) -''' - - -[tool.isort] -profile = "attrs" -line_length = 88 - - -[tool.ruff.isort] -# Match isort's "attrs" profile -lines-after-imports = 2 +[tool.ruff] +src = ["src", "tests", "docs"] + +[tool.ruff.lint] +select = [ + "E", # pycodestyle errors + "F", # pyflakes + "I", # isort + "UP", # pyupgrade + "W", # pycodestyle warnings +] +ignore = [ + "E501", # leave line-length enforcement to ruff format +] + + +[tool.ruff.lint.isort] lines-between-types = 1 +lines-after-imports = 2 [tool.mypy] diff --git a/src/towncrier/_builder.py b/src/towncrier/_builder.py index 61eeb60d..fc93d2c3 100644 --- a/src/towncrier/_builder.py +++ b/src/towncrier/_builder.py @@ -12,7 +12,7 @@ from collections.abc import Iterable, Iterator, Mapping, Sequence from fnmatch import fnmatch from pathlib import Path -from typing import Any, DefaultDict, NamedTuple +from typing import Any, NamedTuple from click import ClickException from jinja2 import Template @@ -138,7 +138,7 @@ def find_fragments( fragment_files = [] # Multiple orphan news fragments are allowed per section, so initialize a counter # that can be incremented automatically. - orphan_fragment_counter: DefaultDict[str | None, int] = defaultdict(int) + orphan_fragment_counter: defaultdict[str | None, int] = defaultdict(int) for key, section_dir in config.sections.items(): section_dir = get_section_path(section_dir) @@ -193,9 +193,7 @@ def find_fragments( if (issue, category, counter) in file_content: raise ValueError( - "multiple files for {}.{} in {}".format( - issue, category, section_dir - ) + f"multiple files for {issue}.{category} in {section_dir}" ) file_content[issue, category, counter] = data diff --git a/src/towncrier/click_default_group.py b/src/towncrier/click_default_group.py index a50cce0d..80e89faf 100644 --- a/src/towncrier/click_default_group.py +++ b/src/towncrier/click_default_group.py @@ -52,6 +52,7 @@ def bar(): bar """ + import warnings import click @@ -115,7 +116,7 @@ def command(self, *args, **kwargs): if not default: return decorator warnings.warn( - "Use default param of DefaultGroup or " "set_default_command() instead", + "Use default param of DefaultGroup or set_default_command() instead", DeprecationWarning, ) diff --git a/src/towncrier/create.py b/src/towncrier/create.py index e78fb658..72f319eb 100644 --- a/src/towncrier/create.py +++ b/src/towncrier/create.py @@ -145,7 +145,7 @@ def __main( click.echo("Pick a section:") default_section_index = None for i, s in enumerate(sections): - click.echo(f" {i+1}: {s or '(primary)'}") + click.echo(f" {i + 1}: {s or '(primary)'}") if not default_section_index and s == section: default_section_index = str(i + 1) section_index = click.prompt( @@ -174,7 +174,7 @@ def __main( file_dir, ( f"{config.orphan_prefix}{os.urandom(4).hex()}" - f"{file_basename[len(config.orphan_prefix):]}" + f"{file_basename[len(config.orphan_prefix) :]}" ), ) filename_parts = filename.split(".") diff --git a/src/towncrier/test/helpers.py b/src/towncrier/test/helpers.py index e7fcde4c..35f948c7 100644 --- a/src/towncrier/test/helpers.py +++ b/src/towncrier/test/helpers.py @@ -56,7 +56,7 @@ def setup_simple_project( mkdir_newsfragments: bool = True, ) -> None: if config is None: - config = "[tool.towncrier]\n" 'package = "foo"\n' + extra_config + config = '[tool.towncrier]\npackage = "foo"\n' + extra_config else: config = textwrap.dedent(config) Path(pyproject_path).write_text(config) diff --git a/src/towncrier/test/test_build.py b/src/towncrier/test/test_build.py index 7ff1ecab..e8b125fb 100644 --- a/src/towncrier/test/test_build.py +++ b/src/towncrier/test/test_build.py @@ -62,8 +62,7 @@ def _test_command(self, command, runner): self.assertEqual(0, result.exit_code, result.output) self.assertEqual( result.output, - dedent( - """\ + dedent("""\ Loading template... Finding news fragments... Rendering news fragments... @@ -89,8 +88,7 @@ def _test_command(self, command, runner): - """ - ), + """), ) def test_command(self): @@ -254,41 +252,31 @@ def run_order_scenario(sections, types): with runner.isolated_filesystem(): with open("pyproject.toml", "w") as f: f.write( - dedent( - """ + dedent(""" [tool.towncrier] package = "foo" directory = "news" - """ - ) + """) ) for section in sections: f.write( - dedent( - """ + dedent(f""" [[tool.towncrier.section]] path = "{section}" name = "{section}" - """.format( - section=section - ) - ) + """) ) for type_ in types: f.write( - dedent( - """ + dedent(f""" [[tool.towncrier.type]] directory = "{type_}" name = "{type_}" showcontent = true - """.format( - type_=type_ - ) - ) + """) ) os.mkdir("foo") @@ -565,8 +553,7 @@ def test_projectless_changelog(self, runner): self.assertEqual(0, result.exit_code) self.assertEqual( result.output, - dedent( - """ + dedent(""" Loading template... Finding news fragments... Rendering news fragments... @@ -584,8 +571,7 @@ def test_projectless_changelog(self, runner): - """ - ).lstrip(), + """).lstrip(), ) @with_project( @@ -609,8 +595,7 @@ def test_version_in_config(self, runner): self.assertEqual(0, result.exit_code, result.output) self.assertEqual( result.output, - dedent( - """ + dedent(""" Loading template... Finding news fragments... Rendering news fragments... @@ -627,8 +612,7 @@ def test_version_in_config(self, runner): - """ - ).lstrip(), + """).lstrip(), ) @with_project( @@ -654,8 +638,7 @@ def test_project_name_in_config(self, runner): self.assertEqual(0, result.exit_code, result.output) self.assertEqual( result.output, - dedent( - """ + dedent(""" Loading template... Finding news fragments... Rendering news fragments... @@ -672,8 +655,7 @@ def test_project_name_in_config(self, runner): - """ - ).lstrip(), + """).lstrip(), ) @with_project(config="[tool.towncrier]") @@ -697,8 +679,7 @@ def test_no_package_changelog(self, runner): self.assertEqual(0, result.exit_code, result.output) self.assertEqual( result.output, - dedent( - """ + dedent(""" Loading template... Finding news fragments... Rendering news fragments... @@ -715,8 +696,7 @@ def test_no_package_changelog(self, runner): - """ - ).lstrip(), + """).lstrip(), ) @with_project( @@ -774,8 +754,7 @@ def do_build_once_with(version, fragment_file, fragment): self.assertEqual( outputs[0], - dedent( - """ + dedent(""" foo 7.8.9 (01-01-2001) ====================== @@ -783,13 +762,11 @@ def do_build_once_with(version, fragment_file, fragment): -------- - Adds levitation (#123) - """ - ).lstrip(), + """).lstrip(), ) self.assertEqual( outputs[1], - dedent( - """ + dedent(""" foo 7.9.0 (01-01-2001) ====================== @@ -797,8 +774,7 @@ def do_build_once_with(version, fragment_file, fragment): -------- - Adds catapult (#456) - """ - ).lstrip(), + """).lstrip(), ) @with_project( @@ -883,8 +859,7 @@ def do_build_once_with(version, fragment_file, fragment): self.assertEqual( output, - dedent( - """ + dedent(""" foo 7.9.0 (01-01-2001) ====================== @@ -901,8 +876,7 @@ def do_build_once_with(version, fragment_file, fragment): -------- - Adds levitation (#123) - """ - ).lstrip(), + """).lstrip(), ) @with_project( @@ -947,8 +921,7 @@ def test_bullet_points_false(self, runner): self.assertEqual( output, - dedent( - """ + dedent(""" foo 7.8.9 (01-01-2001) ====================== @@ -981,8 +954,7 @@ def test_bullet_points_false(self, runner): - Hyphen based bullet list. (#125) - """ - ).lstrip(), + """).lstrip(), ) @with_project( @@ -1015,8 +987,7 @@ def test_title_format_custom(self, runner): ], ) - expected_output = dedent( - """\ + expected_output = dedent("""\ Loading template... Finding news fragments... Rendering news fragments... @@ -1034,8 +1005,7 @@ def test_title_format_custom(self, runner): - """ - ) + """) self.assertEqual(0, result.exit_code) self.assertEqual(expected_output, result.output) @@ -1076,8 +1046,7 @@ def test_title_format_custom_markdown(self, runner): ], ) - expected_output = dedent( - """\ + expected_output = dedent("""\ Loading template... Finding news fragments... Rendering news fragments... @@ -1092,8 +1061,7 @@ def test_title_format_custom_markdown(self, runner): - """ - ) + """) self.assertEqual(0, result.exit_code) self.assertEqual(expected_output, result.output) @@ -1145,8 +1113,7 @@ def test_markdown_injected_after_header(self, runner): self.assertEqual(0, result.exit_code, result.output) output = read("NEWS.md") - expected_output = dedent( - """ + expected_output = dedent(""" # Top title ## Section title @@ -1167,8 +1134,7 @@ def test_markdown_injected_after_header(self, runner): a footer! - """ - ) + """) self.assertEqual(expected_output, output) @@ -1187,8 +1153,7 @@ def test_title_format_false(self, runner): """ with open("template.rst", "w") as f: f.write( - dedent( - """\ + dedent("""\ Here's a hardcoded title added by the template ============================================== {% for section in sections %} @@ -1201,8 +1166,7 @@ def test_title_format_false(self, runner): {% endfor %} {% endfor %} {% endfor %} - """ - ) + """) ) result = runner.invoke( @@ -1219,8 +1183,7 @@ def test_title_format_false(self, runner): catch_exceptions=False, ) - expected_output = dedent( - """\ + expected_output = dedent("""\ Loading template... Finding news fragments... Rendering news fragments... @@ -1230,8 +1193,7 @@ def test_title_format_false(self, runner): Here's a hardcoded title added by the template ============================================== - """ - ) + """) self.assertEqual(0, result.exit_code) self.assertEqual(expected_output, result.output) @@ -1271,8 +1233,7 @@ def test_start_string(self, runner): self.assertTrue(os.path.exists("NEWS.rst"), os.listdir(".")) output = read("NEWS.rst") - expected_output = dedent( - """\ + expected_output = dedent("""\ a line another @@ -1288,8 +1249,7 @@ def test_start_string(self, runner): a footer! - """ - ) + """) self.assertEqual(expected_output, output) @@ -1319,8 +1279,7 @@ def test_default_start_string(self, runner): self.assertEqual(0, result.exit_code, result.output) output = read("NEWS.rst") - expected_output = dedent( - """ + expected_output = dedent(""" a line another @@ -1337,8 +1296,7 @@ def test_default_start_string(self, runner): a footer! - """ - ) + """) self.assertEqual(expected_output, output) @@ -1375,8 +1333,7 @@ def test_default_start_string_markdown(self, runner): self.assertEqual(0, result.exit_code, result.output) output = read("NEWS.md") - expected_output = dedent( - """ + expected_output = dedent(""" a line another @@ -1391,8 +1348,7 @@ def test_default_start_string_markdown(self, runner): a footer! - """ - ) + """) self.assertEqual(expected_output, output) @@ -1429,8 +1385,7 @@ def test_markdown_no_name_title(self, runner): self.assertEqual(0, result.exit_code, result.output) output = read("NEWS.md") - expected_output = dedent( - """ + expected_output = dedent(""" A line @@ -1440,8 +1395,7 @@ def test_markdown_no_name_title(self, runner): ## Features - Adds levitation (#123) - """ - ) + """) self.assertEqual(expected_output, output) @@ -1466,8 +1420,7 @@ def test_with_topline_and_template_and_draft(self, runner): f.write("Adds levitation") with open("template.rst", "w") as f: f.write( - dedent( - """\ + dedent("""\ {% for section in sections %} {% set underline = "-" %} {% for category, val in definitions.items() if category in sections[section] %} @@ -1478,8 +1431,7 @@ def test_with_topline_and_template_and_draft(self, runner): {% endfor %} {% endfor %} {% endfor %} - """ - ) + """) ) result = runner.invoke( @@ -1492,8 +1444,7 @@ def test_with_topline_and_template_and_draft(self, runner): ], ) - expected_output = dedent( - """\ + expected_output = dedent("""\ Loading template... Finding news fragments... Rendering news fragments... @@ -1506,8 +1457,7 @@ def test_with_topline_and_template_and_draft(self, runner): - Adds levitation - """ - ) + """) self.assertEqual(0, result.exit_code, result.output) self.assertEqual(expected_output, result.output) @@ -1541,8 +1491,7 @@ def test_orphans_in_non_showcontent(self, runner): ], ) - expected_output = dedent( - """\ + expected_output = dedent("""\ Loading template... Finding news fragments... Rendering news fragments... @@ -1561,8 +1510,7 @@ def test_orphans_in_non_showcontent(self, runner): - """ - ) + """) self.assertEqual(0, result.exit_code, result.output) self.assertEqual(expected_output, result.output) @@ -1597,8 +1545,7 @@ def test_orphans_in_non_showcontent_markdown(self, runner): ], ) - expected_output = dedent( - """\ + expected_output = dedent("""\ Loading template... Finding news fragments... Rendering news fragments... @@ -1615,8 +1562,7 @@ def test_orphans_in_non_showcontent_markdown(self, runner): - """ - ) + """) self.assertEqual(0, result.exit_code, result.output) self.assertEqual(expected_output, result.output) @@ -1657,8 +1603,7 @@ def test_uncommitted_files(self, runner, commit): news_contents = open(path).read() self.assertEqual( news_contents, - dedent( - """\ + dedent("""\ Foo 1.2.3 (01-01-2001) ====================== @@ -1669,8 +1614,7 @@ def test_uncommitted_files(self, runner, commit): - Extends levitation. File modified in Git. Extended for an hour. (#124) - Baz levitation. Staged file. (#125) - Fix (literal) crash. File unknown to Git. (#126) - """ - ), + """), ) @with_project( @@ -1736,8 +1680,7 @@ def test_ignore_template_filename(self, runner): f.write("Brand new thing.") with open("foo/newsfragments/template.j2", "w") as f: # Just a simple template to check that the file is rendered. - f.write( - """ + f.write(""" {% for section, _ in sections.items() %} {% for category, val in definitions.items() if category in sections[section]%} {{ definitions[category]['name'] }} @@ -1748,8 +1691,7 @@ def test_ignore_template_filename(self, runner): {% endfor %} {% endfor %} -""" - ) +""") result = runner.invoke(_main, ["--draft"]) self.assertEqual(0, result.exit_code, result.output) @@ -1793,8 +1735,7 @@ def test_showcontent_default_toml_array(self, runner): _main, ["--date", "01-01-2001", "--version", "1.0.0", "--yes"] ) news = read("NEWS.rst") - expected = textwrap.dedent( - """\ + expected = textwrap.dedent("""\ 1.0.0 - 01-01-2001 ================== @@ -1802,8 +1743,7 @@ def test_showcontent_default_toml_array(self, runner): ------- - An exciting new feature! - """ - ) + """) self.assertEqual(0, result.exit_code, result.output) self.assertEqual(expected, news, news) @@ -1835,8 +1775,7 @@ def test_directory_default_toml_array(self, runner): _main, ["--date", "01-01-2001", "--version", "1.0.0", "--yes"] ) news = read("NEWS.rst") - expected = textwrap.dedent( - """\ + expected = textwrap.dedent("""\ 1.0.0 - 01-01-2001 ================== @@ -1850,7 +1789,6 @@ def test_directory_default_toml_array(self, runner): ---------- - We bumped our dependencies. - """ - ) + """) self.assertEqual(0, result.exit_code, result.output) self.assertEqual(expected, news, news) diff --git a/src/towncrier/test/test_builder.py b/src/towncrier/test/test_builder.py index 31108fdf..10334b47 100644 --- a/src/towncrier/test/test_builder.py +++ b/src/towncrier/test/test_builder.py @@ -148,8 +148,7 @@ class TestNewsFragmentsOrdering(TestCase): fragments within a section. """ - template = dedent( - """ + template = dedent(""" {% for section_name, category in sections.items() %} {% if section_name %}# {{ section_name }}{% endif %} {%- for category_name, issues in category.items() %} @@ -160,8 +159,7 @@ class TestNewsFragmentsOrdering(TestCase): {% endfor %} {% endfor -%} {% endfor -%} - """ - ) + """) def render(self, fragments): return render_fragments( @@ -198,13 +196,11 @@ def test_ordering(self): ) # "Eggs" are first because they have an issue with no number, and the first # issue for each fragment is what is used for sorting the overall list. - assert output == dedent( - """ + assert output == dedent(""" ## feature - Added Eggs (random, gh-2) - Added Milk (gh-1) - Added Cheese (gh-3, gh-25, #4, #10) - Added Bread - Added Fish -""" - ) +""") diff --git a/src/towncrier/test/test_check.py b/src/towncrier/test/test_check.py index 301735a5..b8ca9897 100644 --- a/src/towncrier/test/test_check.py +++ b/src/towncrier/test/test_check.py @@ -413,8 +413,7 @@ def test_in_different_dir_with_nondefault_newsfragments_directory(self, runner): Path("pyproject.toml").write_text( # Important to customize `config.directory` because the default # already supports this scenario. - "[tool.towncrier]\n" - + 'directory = "changelog.d"\n' + "[tool.towncrier]\n" + 'directory = "changelog.d"\n' ) subproject1 = Path("foo") (subproject1 / "foo").mkdir(parents=True) diff --git a/src/towncrier/test/test_create.py b/src/towncrier/test/test_create.py index dc6f6b9d..4499404e 100644 --- a/src/towncrier/test/test_create.py +++ b/src/towncrier/test/test_create.py @@ -98,13 +98,11 @@ def test_edit_markdown_extension(self): mock_edit.return_value = "This is line 1" self._test_success( content=["This is line 1"], - config=dedent( - """\ + config=dedent("""\ [tool.towncrier] package = "foo" filename = "README.md" - """ - ), + """), additional_args=["--edit"], ) mock_edit.assert_called_once_with( @@ -123,13 +121,11 @@ def test_edit_unknown_extension(self): mock_edit.return_value = "This is line 1" self._test_success( content=["This is line 1"], - config=dedent( - """\ + config=dedent("""\ [tool.towncrier] package = "foo" filename = "README.FIRST" - """ - ), + """), additional_args=["--edit"], ) mock_edit.assert_called_once_with( @@ -153,13 +149,11 @@ def test_content_without_eof_newline(self): argument. The text editor is not invoked, and no eof newline is added if the config option is set. """ - config = dedent( - """\ + config = dedent("""\ [tool.towncrier] package = "foo" create_eof_newline = false - """ - ) + """) content_line = "This is a content" self._test_success( content=[content_line], @@ -190,12 +184,10 @@ def test_message_and_edit(self): def test_different_directory(self): """Ensure non-standard directories are used.""" runner = CliRunner() - config = dedent( - """\ + config = dedent("""\ [tool.towncrier] directory = "releasenotes" - """ - ) + """) with runner.isolated_filesystem(): setup_simple_project(config=config, mkdir_newsfragments=False) @@ -374,11 +366,9 @@ def test_without_filename_orphan(self, runner: CliRunner): mock_edit.assert_called_once() expected = os.path.join(os.getcwd(), "foo", "newsfragments", "+") self.assertTrue( - result.output.startswith( - f"""Issue number (`+` if none): + + result.output.startswith(f"""Issue number (`+` if none): + Fragment type (feature, bugfix, doc, removal, misc): feature -Created news fragment at {expected}""" - ), +Created news fragment at {expected}"""), result.output, ) # Check that the file was created with a random name @@ -646,8 +636,7 @@ def test_in_different_dir_with_nondefault_newsfragments_directory(self, runner): Path("pyproject.toml").write_text( # Important to customize `config.directory` because the default # already supports this scenario. - "[tool.towncrier]\n" - + 'directory = "changelog.d"\n' + "[tool.towncrier]\n" + 'directory = "changelog.d"\n' ) Path("foo/foo").mkdir(parents=True) Path("foo/foo/__init__.py").write_text("") diff --git a/src/towncrier/test/test_project.py b/src/towncrier/test/test_project.py index a93ef190..165f9e55 100644 --- a/src/towncrier/test/test_project.py +++ b/src/towncrier/test/test_project.py @@ -53,8 +53,7 @@ def test_incremental(self): os.makedirs(os.path.join(temp, "mytestprojinc")) with open(os.path.join(temp, "mytestprojinc", "__init__.py"), "w") as f: - f.write( - """ + f.write(""" class Version: ''' This is emulating a Version object from incremental. @@ -68,8 +67,7 @@ def base(self): return '.'.join(map(str, self.version)) __version__ = Version(1, 3, 12, "rc1") - """ - ) + """) version = get_version(temp, "mytestprojinc") self.assertEqual(version, "1.3.12rc1") @@ -88,16 +86,14 @@ def test_not_incremental(self): os.makedirs(os.path.join(temp, "mytestprojnotinc")) with open(os.path.join(temp, "mytestprojnotinc", "__init__.py"), "w") as f: - f.write( - """ + f.write(""" class WeirdVersion: def base(self, some_arg): return "shouldn't get here" __version__ = WeirdVersion() -""" - ) +""") with self.assertRaises(Exception) as e: get_version(temp, "mytestprojnotinc") @@ -235,7 +231,7 @@ def test_dash_m(self): try: os.chdir(new_dir) with open("pyproject.toml", "w") as f: - f.write("[tool.towncrier]\n" 'directory = "news"\n') + f.write('[tool.towncrier]\ndirectory = "news"\n') os.makedirs("news") result = runner.invoke(towncrier_cli, ["--help"]) self.assertIn("[OPTIONS] COMMAND [ARGS]...", result.stdout) diff --git a/src/towncrier/test/test_settings.py b/src/towncrier/test/test_settings.py index f46db2b2..a05cf419 100644 --- a/src/towncrier/test/test_settings.py +++ b/src/towncrier/test/test_settings.py @@ -211,18 +211,14 @@ def test_pyproject_assert_fallback(self): This both tests when things are *only* in the pyproject.toml and default usage of the data in the towncrier.toml file. """ - pyproject_toml = dedent( - """ + pyproject_toml = dedent(""" [project] name = "foo" [tool.towncrier] - """ - ) - towncrier_toml = dedent( - """ + """) + towncrier_toml = dedent(""" [tool.towncrier] - """ - ) + """) tests = [ "", "name = '{name}'", diff --git a/src/towncrier/test/test_write.py b/src/towncrier/test/test_write.py index 563fde6f..a689634e 100644 --- a/src/towncrier/test/test_write.py +++ b/src/towncrier/test/test_write.py @@ -247,12 +247,10 @@ def test_multiple_file_no_start_string(self): with open(os.path.join(tempdir, "NEWS.rst")) as f: output = f.read() - expected_output = dedent( - """\ + expected_output = dedent("""\ MyProject 1.0 (never) ===================== - """ - ) + """) self.assertEqual(expected_output, output) @@ -286,13 +284,11 @@ def do_build_once(): with runner.isolated_filesystem(): with open("pyproject.toml", "w") as f: f.write( - dedent( - """ + dedent(""" [tool.towncrier] title_format="{name} {version} ({project_date})" filename="{version}-notes.rst" - """ - ).lstrip() + """).lstrip() ) with open("{version}-notes.rst", "w") as f: f.write("Release Notes\n\n.. towncrier release notes start\n") @@ -337,14 +333,12 @@ def do_build_once(): with runner.isolated_filesystem(): with open("pyproject.toml", "w") as f: f.write( - dedent( - """ + dedent(""" [tool.towncrier] single_file=false title_format="{name} {version} ({project_date})" filename="{version}-notes.rst" - """ - ).lstrip() + """).lstrip() ) os.mkdir("newsfragments") @@ -361,8 +355,7 @@ def do_build_once(): with open(notes[0]) as f: output = f.read() - expected_output = dedent( - """\ + expected_output = dedent("""\ foo 7.8.9 (01-01-2001) ====================== @@ -370,7 +363,6 @@ def do_build_once(): -------- - Adds levitation (#123) - """ - ) + """) self.assertEqual(expected_output, output)