Skip to content
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

chore!: Replace thiserror with derive_more 1.0 #624

Merged
merged 2 commits into from
Sep 30, 2024
Merged

Conversation

aborgna-q
Copy link
Collaborator

derive_more 1.0 can now be used as a more granular replacement for thiserror.
The main changes required were:

  • Explicit derives for Display and From, in addition to Error.
  • Use #[display(...)] directives instead of #[error(...)]. The syntax is sightly different for referencing tuple elements (_0 vs 0). error(transparent) is also the default behaviour.
  • The new From derive is less intrusive (derives it for every variant non-from(ignore)d, unless explicit variants are picked with #[from]).

Those changes are non-breaking (see first commit). Since the next release will be a breaking one, I included some cleanups too.

  • Added all missing #[non_exhaustive]s to the error enums (this missing is what caused the last breaking change).
  • Converted unary tuple variants into named structs.
    derive_more assumes unary tuples to be an error source, so we had to add #[error(ignore)] in some cases.
  • Add more contexts to some errors (e.g. adding the node id to errors that only printed the port offset).

BREAKING CHANGE: Made all errors non_exhaustive, and renamed some fields for clarity.

Copy link

codecov bot commented Sep 30, 2024

Codecov Report

Attention: Patch coverage is 60.71429% with 11 lines in your changes missing coverage. Please review.

Project coverage is 82.06%. Comparing base (1cf9dcb) to head (5e73761).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
tket2/src/circuit.rs 80.00% 2 Missing and 2 partials ⚠️
tket2/src/portmatching.rs 0.00% 3 Missing ⚠️
tket2-hseries/src/extension/hseries/lower.rs 0.00% 2 Missing ⚠️
tket2/src/passes/commutation.rs 50.00% 1 Missing ⚠️
tket2/src/serialize/guppy.rs 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #624      +/-   ##
==========================================
- Coverage   82.07%   82.06%   -0.02%     
==========================================
  Files          48       48              
  Lines        6556     6572      +16     
  Branches     6556     6572      +16     
==========================================
+ Hits         5381     5393      +12     
- Misses        817      820       +3     
- Partials      358      359       +1     
Flag Coverage Δ
rust 82.06% <60.71%> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Collaborator

@cqc-alec cqc-alec left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@aborgna-q aborgna-q added this pull request to the merge queue Sep 30, 2024
Merged via the queue into main with commit 2250ce7 Sep 30, 2024
15 of 16 checks passed
@aborgna-q aborgna-q deleted the ab/derive_more branch September 30, 2024 14:47
github-merge-queue bot pushed a commit that referenced this pull request Oct 3, 2024
🤖 I have created a release *beep* *boop*
---


##
[0.4.0](tket2-py-v0.3.0...tket2-py-v0.4.0)
(2024-10-01)


### ⚠ BREAKING CHANGES

* Made all errors `non_exhaustive`, and renamed some fields for clarity.
* "tket2.angle" extension replaced with "tket2.rotation" extension with
rotation type and simplified set of operations.
* TryFrom implementations for extension op structs removed, use `cast`

### Features

* `BadgerOptimiser.load_precompiled`, `BadgerOptimiser.compile_eccs` and
`passes.badger_pass` now take an optional `cost_fn` parameter to specify
the cost function to minimise. Supported values are `'cx'` (default
behaviour) and `'rz'`.
([83ebfcb](83ebfcb))
* simplify angle extension in to a half turns rotation type
([#611](#611))
([0723937](0723937))
* Support encoding float and sympy ops
([#618](#618))
([74dcbf7](74dcbf7))
* **tket2-hseries:** cli extension dumping
([#584](#584))
([abf292f](abf292f))


### Bug Fixes

* remove TryFrom for extension ops use `cast`
([#592](#592))
([5ca29af](5ca29af))
* Support hugr packages, fix the notebooks
([#622](#622))
([1cf9dcb](1cf9dcb))


### Documentation

* Add tket2-py module docstring
([#539](#539))
([8ef7a57](8ef7a57))


### Miscellaneous Chores

* Replace thiserror with derive_more 1.0
([#624](#624))
([2250ce7](2250ce7))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

---------

Co-authored-by: Agustín Borgna <[email protected]>
Co-authored-by: Agustín Borgna <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants