-
Notifications
You must be signed in to change notification settings - Fork 123
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allowed fallback usage of project.name
for name
and package
if pyproject.toml exists
#687
Conversation
This fallback will only work if the pyproject.toml file is present. However, it will work for any combination of pyproject.toml or towncrier.toml configuration files. Note, that project.name is a required field in pyproject.toml files. Hence, the minimal requirement for using towncrier in python project is a no-op! Signed-off-by: Nick Papior <nickpapior@gmail.com>
Signed-off-by: Nick Papior <nickpapior@gmail.com>
Signed-off-by: Nick Papior <nickpapior@gmail.com>
Due to the lifting of minimal configuration in python projects the entry is not required any more. Signed-off-by: Nick Papior <nickpapior@gmail.com>
So this drastically changes the requirement of having a So unless that is a big objection, I think this is a more or less complete PR that catches undefined |
One thing, you said I should use the metadata, but I am inclined not to. That would only work for Python projects, and so the path would be something like: project_name = pyproject_config["project"]["name"]
project_name = importlib.metadata.metadata(project_name)["Name"] is this more in line with what you want? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Many thanks for the PR.
I am quite busy these days and I don't have much time for side-projects.
I tried to do a quick review.
Can you update the PR title to provide a summary of what is done here?
Do you want a test for the last thing not covered?
If this is a functionality that is documented, then we need automated tests.
If the functionality is not documented and has no tests, then this is an "accidental" feature and it might break any time in the future.
One thing, you said I should use the metadata, but I am inclined not to. That would only work for Python projects, and so the path would be something like:
I am ok with the current implementation.
No need to extract the package name from importlib.metadata
As long as we don't break backward compatility, anyting should be ok
Do have a test that proves that if we have
[project]
name = "Dull Pants"
[tool.towncrier]
name = "Fancy Pants"
package = fancy_pants
the config will prefer the value from [tool.towncrier]
?
Thanks again
@@ -112,22 +112,6 @@ def test_template_extended(self): | |||
|
|||
self.assertEqual(config.template, ("towncrier.templates", "default.rst")) | |||
|
|||
def test_missing(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why was this test removed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
because now towncrier
does not need any tool.towncrier
section for Python projects using pyproject.toml
files.
A pyproject.toml
file requires the name
field, and hence everything can be used without problems.
The removed test checked that it broke when tool.towncrier
was not present, simply because it is not required.
@@ -194,6 +178,42 @@ def test_towncrier_toml_preferred(self): | |||
config = load_config(project_dir) | |||
self.assertEqual(config.package, "a") | |||
|
|||
def test_pyproject_name_fallback_both(self): | |||
""" | |||
Towncrier will fallback to the [project.name] value in pyproject.toml. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a small suggestion to help understand the scope of this test.
Towncrier will fallback to the [project.name] value in pyproject.toml. | |
To obtain the name of the project, when there is no dedicated [tool.towncrier] section in pyproject.toml, it will fallback to the `name` option from the [project] section. |
Just asking. Is towncrier
usable without a configuration section ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. When it is a Python project with a pyproject.toml
file, then a configuration file / setting is not required.
project.name
for name
and package
if pyproject.toml exists
Signed-off-by: Nick Papior <nickpapior@gmail.com>
Signed-off-by: Nick Papior <nickpapior@gmail.com>
done! I think everything is done, let me know if there is something that needs clarification. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. Great work! Thanks again for the PR.
Description
Fixes #685
Checklist
src/towncrier/newsfragments/
. Briefly describe yourchanges, with information useful to end users. Your change will be included in the public release notes.
docs/tutorial.rst
is still up-to-date.docs/cli.rst
reflects those changes.docs/configuration.rst
reflects those changes.