Repository navigation
Deprecated author and author_email for authors according to PEP621 - #3131
garvitshrma wants to merge 5 commits into
Conversation
7351b4a to
ea3d2cf
Compare
freakboy3742
left a comment
There was a problem hiding this comment.
This is a good starting point, and it looks like you've found most of the moving parts that are involved; however, it's not quite there yet.
The key detail that is missing: although we need to continue to accept author and author_email, as configuration values, the GlobalConfig and AppConfig should only be storing those values in the new "canonical" form - authors. There should be no references to author and author_email in the code, other than those necessary to process historical config files (and any time those historical settings are found, a warning should be raised).
Some of the logic that exists in parse_config is there to coerce a PEP 621 authors definition into Briefcase's definition; we need to reverse that, and coerce a historical Briefcase definition into PEP 621 form.
This may have some consequences outside the config files - for example, the create command references app.author and app.author_email when writing the app's dist_info. That reference needs to be updated to use the new app.authors. There's a couple of similar references in linux and windows packaging backends.
…ngs from docs, improved config.py to match the suggested improvement
freakboy3742
left a comment
There was a problem hiding this comment.
This is definitely headed in the right direction; a couple of minor suggestions inline.
The approach you've taken in the create method looks about right to me. I'll admit I was a little surprised by the comma-concatenation, but I've confirmed that is what the dist-info file expects, so you've done the right thing there.
The test failures you're seeing at present have two causes:
- The configuration tests are currently configured to expect to see
authorandauthor_emailin generated configurations, but with your changes, those keys are no longer generated. I flagged one of these in the review (the comment about updating the configuration to use the "current good" output); but there will be a couple of test configurations that currently defineauthorandauthor_emailthat need to be updated to defineauthorsinstead. - Coverage - you've added some new code paths that aren't tested. The coverage report is outputting:
Name Stmts Miss Branch BrPart Cover Missing
------------------------------------------------------------------------------
src/briefcase/commands/create.py 425 6 106 4 97.4% 77-78, 83-84, 88, 90
------------------------------------------------------------------------------
TOTAL 9335 6 2296 4 99.9%
So - in your code, Lines 77-78, 83-84, 88 and 90 of create.py aren't being executed by the test suite. Looking at the code, this suggests the tests that are exercising the write_dist_info method aren't passing in an authors configuration - so it's falling through to an empty list.
You'll likely also need to add some new test cases; at present, it's not possible to define an app that only has a name, or only has an email; so those branches won't be covered at present either.
The last piece that is missing is to update the references in the Linux and Windows backends to author and author_name. The Linux configurations will involve some research into how Linux system packaging tools (like RPM) express multiple authors; on Windows, there's a reference to app.author when running RCEdit. The fix there will likely be to just use the first author.
There's also the question of what happens when the user doesn't define authors, or defines an empty authors list. Strictly, PEP 621 doesn't require an author; we need to confirm if Linux and/or Windows has a problem if the author fields are omitted.
| url: str | None | ||
| author: str | None | ||
| author_email: str | None | ||
| authors: list[dict] | None |
There was a problem hiding this comment.
We can go a little tighter with this type specification:
| authors: list[dict] | None | |
| authors: list[dict[str, str]] | None |
| author = global_config.pop("author", None) | ||
| author_email = global_config.pop("author_email", None) | ||
|
|
||
| if "authors" not in global_config and (author or author_email): |
There was a problem hiding this comment.
What happens in the case here the global config has authors and author (or authors and author_email)? I'd suggest we should raise an error, as it's an indication that the user is split across 2 different configuration schema.
| Update your configuration to use `authors`: | ||
|
|
||
| authors = [ | ||
| {name = "Jane Developer", email = "jane@example.com"}, |
There was a problem hiding this comment.
We're in a position to provide the actual drop-in configuration here - we know what the actual name and email configuration should be, so the error message use that text directly.
|
|
||
| # Must run before the PEP 621 merge, which removes the historical | ||
| # `author`/`author_email` settings once they have been coerced. | ||
| warn_deprecated_author_config(global_config, console) |
There was a problem hiding this comment.
Would it not make sense to keep all the deprecation code in one place? That way, when we finally finalise the deprecation, it should be a simple "delete this one function call" diff.
| "author": "First Last", | ||
| "author_email": "first@example.com", | ||
| "authors": None, |
There was a problem hiding this comment.
In general, we try to keep our test cases "up to date" - that is, reflecting a "good", current configuration; and then make special cases of the configurations needed for testing historical/migration purposes.
| "author": "First Last", | |
| "author_email": "first@example.com", | |
| "authors": None, | |
| "authors": [{"name": "First Last", "email": "first@example.com"}], |
|
One more thing to add to your testing regimen - we just received a PR that drew my attention to #2120. As part of this work, we'll need to remove the support for converting PEP 621 author names Briefcase-style author definitions in the |
0c7e7a6 to
d92d16b
Compare
I have deprecated the
authorandauthor_emailsettings in favour ofauthors, following the PEP 621 configuration. A warning is now printed when a user uses the old settings (authorandauthor_email). I have also added a note in the docs mentioning the deprecation of the two old settings. I have addedauthorsas a list in every place.authorsnow contains both the author name and email.Briefcase now follows the PEP 621 guidelines for the author settings.
Refs #1235
PR Checklist:
Assisted-by: Claude Opus 5