Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions .flake8

This file was deleted.

24 changes: 5 additions & 19 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 0 additions & 2 deletions bin/towncrier
Original file line number Diff line number Diff line change
Expand Up @@ -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()
5 changes: 1 addition & 4 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 1 addition & 3 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -83,8 +82,7 @@ def docs(session: nox.Session) -> None:
"-D", "language=en",
"docs",
"docs/_build/html",
# fmt: on
)
) # fmt: skip


@nox.session
Expand Down
47 changes: 18 additions & 29 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
8 changes: 3 additions & 5 deletions src/towncrier/_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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

Expand Down
3 changes: 2 additions & 1 deletion src/towncrier/click_default_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ def bar():
bar

"""

import warnings

import click
Expand Down Expand Up @@ -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,
)

Expand Down
4 changes: 2 additions & 2 deletions src/towncrier/create.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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(".")
Expand Down
2 changes: 1 addition & 1 deletion src/towncrier/test/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Loading
Loading