Skip to content

Commit

Permalink
Merge branch 'trunk' into remove-incremental
Browse files Browse the repository at this point in the history
  • Loading branch information
hynek authored Jul 9, 2023
2 parents accc883 + 2d47105 commit aa5e214
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 9 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -149,10 +149,10 @@ jobs:
fail-fast: false
matrix:
python:
# Using second most recent minor release for whatever little
# increase in stability over using the latest minor.
- name: CPython 3.9
python-version: '3.9'
# Use a recent version to avoid having common disconnects between
# local development setups and CI.
- name: CPython 3.11
python-version: '3.11'
task:
- name: Check Newsfragment
nox: check_newsfragment
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ repos:
- id: black

- repo: https:/asottile/pyupgrade
rev: v3.4.0
rev: v3.8.0
hooks:
- id: pyupgrade
args: [--py38-plus]
Expand Down
4 changes: 3 additions & 1 deletion noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@ def check_newsfragment(session: nox.Session) -> None:

@nox.session
def typecheck(session: nox.Session) -> None:
session.install(".", "mypy")
# Click 8.1.4 is bad type hints -- lets not complicate packaging and only
# pin here.
session.install(".", "mypy", "click!=8.1.4")
session.run("mypy", "src")


Expand Down
12 changes: 10 additions & 2 deletions src/towncrier/_settings/load.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,9 @@ def parse_toml(base_path: str, config: Mapping[str, Any]) -> Config:
package, resource = template.split(":", 1)
if not Path(resource).suffix:
resource += ".md" if markdown_file else ".rst"
if not resources.is_resource(package, resource):
if resources.is_resource(package + ".templates", resource):

if not _pkg_file_exists(package, resource):
if _pkg_file_exists(package + ".templates", resource):
package += ".templates"
else:
raise ConfigError(
Expand Down Expand Up @@ -190,3 +191,10 @@ def parse_toml(base_path: str, config: Mapping[str, Any]) -> Config:

# Return the parsed config.
return Config(**parsed_data)


def _pkg_file_exists(pkg: str, file: str) -> bool:
"""
Check whether *file* exists within *pkg*.
"""
return resources.files(pkg).joinpath(file).is_file()
4 changes: 3 additions & 1 deletion src/towncrier/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,9 @@ def __main(

click.echo("Loading template...", err=to_err)
if isinstance(config.template, tuple):
template = resources.read_text(*config.template)
template = (
resources.files(config.template[0]).joinpath(config.template[1]).read_text()
)
else:
with open(config.template, encoding="utf-8") as tmpl:
template = tmpl.read()
Expand Down
Empty file.

0 comments on commit aa5e214

Please sign in to comment.