From 9ca2659b8bf13d4d1e3cc3a8a08a1b034f895f23 Mon Sep 17 00:00:00 2001 From: Steve Wooster Date: Mon, 29 Jan 2024 13:22:54 -0800 Subject: [PATCH] Appease clippy (and black) (#51) * Use `Vec::with_capacity` instead of `Vec::reserve` where appropriate * Don't import * from `python_api` when it doesn't have anything to import * Reformat `quickdna` Python module --- quickdna/__init__.py | 6 ++---- src/lib.rs | 3 --- src/rust_api.rs | 4 +--- 3 files changed, 3 insertions(+), 10 deletions(-) diff --git a/quickdna/__init__.py b/quickdna/__init__.py index 5fe4619..71cf92a 100644 --- a/quickdna/__init__.py +++ b/quickdna/__init__.py @@ -35,12 +35,10 @@ def seq(self) -> bytes: return self._seq @ty.overload - def __getitem__(self, __i: ty.SupportsIndex) -> int: - ... + def __getitem__(self, __i: ty.SupportsIndex) -> int: ... @ty.overload - def __getitem__(self: T, __s: slice) -> T: - ... + def __getitem__(self: T, __s: slice) -> T: ... def __getitem__(self, key): if isinstance(key, ty.SupportsIndex): diff --git a/src/lib.rs b/src/lib.rs index 08314b3..531f6d7 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -27,9 +27,6 @@ pub use rust_api::*; #[cfg(feature = "python-support")] mod python_api; -#[cfg(feature = "python-support")] -pub use python_api::*; - #[cfg(any(feature = "quickcheck", test))] mod quickcheck; diff --git a/src/rust_api.rs b/src/rust_api.rs index 00fe78f..f52f217 100644 --- a/src/rust_api.rs +++ b/src/rust_api.rs @@ -311,9 +311,7 @@ impl TryFrom<&[u8]> for DnaSequence { type Error = TranslationError; fn try_from(value: &[u8]) -> Result { - let mut vec = vec![]; - vec.reserve(value.len()); - + let mut vec = Vec::with_capacity(value.len()); for &b in value { if b != b' ' && b != b'\t' { vec.push(T::try_from(b)?);