-
Notifications
You must be signed in to change notification settings - Fork 15
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
feat: POC header comment API design #332
Conversation
bccef4b
to
771ecfb
Compare
I think this is the best way to have implemented this. The As for deprecating the old method and adding a new one, |
8bda674
to
7d593d7
Compare
@sunipkm thanks for the feedback.
Your comment made me think of a backwards-compatible way of implementing this! I now implement My concern is that this seems like a backwards-compatible change, but it might not be. I think it now hugely depends on the type inference used by the caller. If it is not ambiguous (e.g. they pass the header value to a function that accepts an
Are you sure you want to cite the Python 2 -> 3 transition?!?!?! (I remember it being painless for the most part, but I waited ages to upgrade, by which time the libraries I used had caught up.) I appreciate the idea of moving fast and breaking things, which we can do as we are pre-1.0, however I value stability higher than API correctness. @cjordan: as a user of this crate, does your current code compile if you check out this branch? |
Note: the coverage has gone down because we include some functionality for the |
Hi @simonrw. I'm not able to check that this change will affect the code I used to work on (as of this year, I'm also an ex-astronomer), because those crates depend on |
@simonrw haha I did the same, waited till Py 2.7 went EOL. I guess Py 2 -> 3 transition isn’t the best example but the point I was trying to make is, we should encourage the assignment of the more flexible interface/implementation to the easier-to-read method name, because those stick. If we deprecate read_keys now with the old behavior, shouldn’t we technically remove that method in the future completely and not replace it with the new behavior method, since the calling conventions will be different? I agree on the point that you bring up, that it looks backwards compatible but it isn’t. I guess as long as function calls are mostly fine, it should be alright for the end user. String conversion of a number and read-back of it may be error prone anyway, e.g. how 268 is ambiguous unless we know the number system used to write it — and this bit of inconsistency/inconvenience now will greatly benefit the users down the line. |
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.
Thanks both for your comments. I think it is safe to release this with a minor (so pre-release major) bump. I think type inference should revert to the old read_key
implementation, or the user would have to be explicit about the type anyway, so I think we are ok.
eb2ec2a
to
6c7fc37
Compare
## 🤖 New release * `fitsio`: 0.21.2 -> 0.21.3 * `fitsio-sys`: 0.5.2 -> 0.5.3 * `fitsio-derive`: 0.2.0 -> 0.2.1 <details><summary><i><b>Changelog</b></i></summary><p> ## `fitsio` <blockquote> ## [0.21.3](fitsio-v0.21.2...fitsio-v0.21.3) - 2024-07-26 ### Added - POC header comment API design ([#332](#332)) ### Other - Add TSHORT types for i16 and u16 - Add clippy feature - Merge branch 'main' into main - Pin minimal serde version - Update criterion requirement from 0.3.5 to 0.5.1 in /fitsio - Fix nightly compile errors - Use TBYTE for *8 reads ([#277](#277)) - Allow/fix warnings that are blocking CI </blockquote> ## `fitsio-sys` <blockquote> ## [0.5.3](fitsio-sys-v0.5.2...fitsio-sys-v0.5.3) - 2024-07-26 ### Other - Fix clippy warnings - Update bindgen requirement from 0.66 to 0.69 in /fitsio-sys - Include new changelog for fitsio-sys - Provide aliases to function "long names". - Update bindgen requirement from 0.63 to 0.66 in /fitsio-sys ### Added * Added aliases for cfitsio short names ([#258](#258)) ### Changed ### Removed </blockquote> ## `fitsio-derive` <blockquote> ## [0.2.1](fitsio-derive-v0.2.0...fitsio-derive-v0.2.1) - 2024-07-26 ### Other - Rename myself - Specify required patch versions for all deps. </blockquote> </p></details> --- This PR was generated with [release-plz](https://github.com/MarcoIeni/release-plz/). --------- Co-authored-by: Simon Walker <[email protected]>
Motivation
Inspired by #307, can we design a nice API to read/write comments of header cards?
Changes
write_key
takes either a simple value, or a tuple of (value, comment) for writing commentsread_key
returns a new structured type which contains both the value and commentheaders
module with previous codeconstants
module, mostly with header related lengthsheader_value
module defining theHeaderValue<T>
type along with its std trait implementationsTODO
write_key
supportread_key
supportread_key
take either a primitive value (backwards compatible) orHeaderValue<_>
HeaderValue
internals? Or remove methods