-
Notifications
You must be signed in to change notification settings - Fork 165
Implement YearRange and CopyrightNotice #1145
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
base: main
Are you sure you want to change the base?
Conversation
80c1953
to
7f871ea
Compare
9156136
to
73729eb
Compare
So this is basically done. All tests pass, and the whole code base is converted to using these new data types instead of strings. There are probably some comments or variable names that still hint at the old string types, or patterns in the code that make less sense given the new data types, but on the whole, everything appears to work. The benefits of doing this aren't immediately obvious yet, except that #328 is now implemented in an obvious and elegant way that doesn't require dark string manipulation magics. The downside is that the new data type is somewhat less flexible than strings. It has some assumptions (years come before the author, separated by spaces, dashes, and commas; contacts are between square brackets at the end; etc etc etc), and tries to remain flexible outside of those assumptions (that is: put everything that isn't recognised into the The other downside is that one test is broken on Windows. I'll fix that, probably. |
the :class:`CopyrightPrefix`es, the most common is chosen. If there is a | ||
tie in frequency, choose the one which appears first in the enum. | ||
""" | ||
# TODO: Consider making a match on contact optional. |
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.
Don't do this; name collisions
Signed-off-by: Carmen Bianca BAKKER <[email protected]>
This is the basis for refactoring ReuseInfo to use CopyrightNotice instead of strings for copyright lines. Signed-off-by: Carmen Bianca BAKKER <[email protected]>
Signed-off-by: Carmen Bianca BAKKER <[email protected]>
Signed-off-by: Carmen Bianca BAKKER <[email protected]>
Signed-off-by: Carmen Bianca BAKKER <[email protected]>
ReuseInfo will depend on CopyrightNotice, so it makes sense to move it. Signed-off-by: Carmen Bianca BAKKER <[email protected]>
These functions were causing cyclical import problems. Signed-off-by: Carmen Bianca BAKKER <[email protected]>
These should be immutable. Editing them makes `orginal` useless. Signed-off-by: Carmen Bianca BAKKER <[email protected]>
This object needs to be hashable, and lists aren't hashable. Altogether a simple change.
This is more correct with the newly created class CopyrightNotice. It will also help identify the spots to refactor, because everything is broken now. Effectively every single line touched by this commit needs a touch-up.
- I made the regex patterns public so that others can use them. - For efficiency, CopyrightNotice.from_match now exists. You can match a file against the COPYRIGHT_PATTERN, and pass the results to the new factory. - I stripped trailing whitespace using the regex.
I don't believe the error can ever be reached given the regex. This should be fine.
A small refactoring.
This apparently wasn't enabled because the tests themselves weren't typed. By enabling `check_untyped_defs`, all calls made inside of test functions are type-checked. I need this as a sanity check because I am changing the type of a very core component used _everywhere_.
While doing this, I changed the return type from YearRange.compact to tuple.
This is, I believe, the last module that needed refactoring.
The symbol © was not correctly encoded into UTF-8 without explicitly declaring the encoding, and reuse assumes UTF-8 encoding in all files.
e37e600
to
dadee74
Compare
`2017 -2019` and `2017 -2019` are not valid. This code ensures that an appropriate error is raised, and also ensures that tuple_from_string splits on correct whitespace.
This is preliminary work for #947.
I'd like to merge this before I work on the refactoring. It will keep these PRs smaller.
changelog.d/<directory>/
.reuse annotate --year
works differently now.the current specification.
changed files.