-
Notifications
You must be signed in to change notification settings - Fork 0
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
[FCL-533] ⚠️ Introduce methods to select the best identifier in various cases #810
[FCL-533] ⚠️ Introduce methods to select the best identifier in various cases #810
Conversation
…when testing required attributes Using `getattr` with a default of `False` will raise an unexpected error when the attribute is present and has a value of `False`. `hasattr` simply checks for its existence, regardless of value.
This allows us to decide which of a range of possible identifiers should be preferred for a document
This is instead of assuming that an NCN will always be present. As a result, this has had knock-on changes in some other places which were previously relying on this incorrect behaviour. This includes some breaking changes to method signatures, which can now return a `None` in places they previously could not. Since relying on the presence of an NCN is now considered dangerous, these methods have been marked as deprecated. BREAKING CHANGE: Methods which were previously guaranteed to return a Neutral Citation may now return `None`.
7cf2d3c
to
eabfe34
Compare
eabfe34
to
b204454
Compare
Typically, this will be the neutral citation number, should it exist. | ||
Should typically be overridden in subclasses. | ||
""" | ||
def best_human_identifier(self) -> Optional[Identifier]: |
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.
Do all identifiers have a sensible __str__
such that this is a good drop-in replacement despite the type change? (It's probably just the value
)
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.
No, but I want this to explode where we're not using it properly. This is definitely a breaking change.
Could you check whether this causes any typing issues in EUI/PUI? |
It definitely does cause typing problems, but they're expected (eg it's places where the apps assume documents always have NCNs). I'm in the process of fixing in EUI (see #1812), and this will be a major version bump. |
BREAKING CHANGE
None
.Feat
Fix