Skip to content

Commit

Permalink
Appease clippy (and black) (#51)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
swooster authored Jan 29, 2024
1 parent 0d015f2 commit 9ca2659
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 10 deletions.
6 changes: 2 additions & 4 deletions quickdna/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
3 changes: 0 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
4 changes: 1 addition & 3 deletions src/rust_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -311,9 +311,7 @@ impl<T: NucleotideLike> TryFrom<&[u8]> for DnaSequence<T> {
type Error = TranslationError;

fn try_from(value: &[u8]) -> Result<Self, Self::Error> {
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)?);
Expand Down

0 comments on commit 9ca2659

Please sign in to comment.