From 481334f13910767350247296469bbf7aa5ff575c Mon Sep 17 00:00:00 2001 From: Marquess Valdez Date: Thu, 11 Jan 2024 10:44:38 -0800 Subject: [PATCH] ci: Use trusted publishing for PyPI (#327) * ci: Use trusted publishing for PyPI * remove unused import * shuffle test modules to bottom for clippy --- .github/workflows/publish-quil-py.yml | 5 +-- quil-rs/src/instruction/calibration.rs | 60 +++++++++++++------------- quil-rs/src/parser/mod.rs | 2 +- 3 files changed, 33 insertions(+), 34 deletions(-) diff --git a/.github/workflows/publish-quil-py.yml b/.github/workflows/publish-quil-py.yml index 67fc80f5..c0ea54c4 100644 --- a/.github/workflows/publish-quil-py.yml +++ b/.github/workflows/publish-quil-py.yml @@ -162,12 +162,11 @@ jobs: # can be published. needs: [ macos, linux, windows, sdist ] if: always() && needs.sdist.result == 'success' + permissions: + id-token: write steps: - uses: actions/download-artifact@v3 - name: Publish to PyPi - env: - MATURIN_USERNAME: ${{ secrets.PYPI_USERNAME }} - MATURIN_PASSWORD: ${{ secrets.PYPI_PASSWORD }} uses: messense/maturin-action@v1 with: command: upload diff --git a/quil-rs/src/instruction/calibration.rs b/quil-rs/src/instruction/calibration.rs index d9e99e53..4aac5b6e 100644 --- a/quil-rs/src/instruction/calibration.rs +++ b/quil-rs/src/instruction/calibration.rs @@ -67,6 +67,36 @@ pub struct MeasureCalibrationDefinition { pub instructions: Vec, } +impl MeasureCalibrationDefinition { + pub fn new(qubit: Option, parameter: String, instructions: Vec) -> Self { + Self { + qubit, + parameter, + instructions, + } + } +} + +impl Quil for MeasureCalibrationDefinition { + fn write( + &self, + f: &mut impl std::fmt::Write, + fall_back_to_debug: bool, + ) -> crate::quil::ToQuilResult<()> { + write!(f, "DEFCAL MEASURE")?; + if let Some(qubit) = &self.qubit { + write!(f, " ")?; + qubit.write(f, fall_back_to_debug)?; + } + + writeln!(f, " {}:", self.parameter,)?; + + write_instruction_block(f, fall_back_to_debug, &self.instructions)?; + writeln!(f)?; + Ok(()) + } +} + #[cfg(test)] mod test_measure_calibration_definition { use super::MeasureCalibrationDefinition; @@ -113,33 +143,3 @@ mod test_measure_calibration_definition { }) } } - -impl MeasureCalibrationDefinition { - pub fn new(qubit: Option, parameter: String, instructions: Vec) -> Self { - Self { - qubit, - parameter, - instructions, - } - } -} - -impl Quil for MeasureCalibrationDefinition { - fn write( - &self, - f: &mut impl std::fmt::Write, - fall_back_to_debug: bool, - ) -> crate::quil::ToQuilResult<()> { - write!(f, "DEFCAL MEASURE")?; - if let Some(qubit) = &self.qubit { - write!(f, " ")?; - qubit.write(f, fall_back_to_debug)?; - } - - writeln!(f, " {}:", self.parameter,)?; - - write_instruction_block(f, fall_back_to_debug, &self.instructions)?; - writeln!(f)?; - Ok(()) - } -} diff --git a/quil-rs/src/parser/mod.rs b/quil-rs/src/parser/mod.rs index 86778b09..3983acb1 100644 --- a/quil-rs/src/parser/mod.rs +++ b/quil-rs/src/parser/mod.rs @@ -31,7 +31,7 @@ mod token; pub(crate) use error::{ErrorInput, InternalParseError}; pub use error::{ParseError, ParserErrorKind}; -pub use lexer::{LexError, LexErrorKind}; +pub use lexer::LexError; pub use token::{Token, TokenWithLocation}; type ParserInput<'a> = &'a [TokenWithLocation<'a>];