Skip to content

Commit

Permalink
Ruff lint fixes (scikit-bio#1922)
Browse files Browse the repository at this point in the history
* fixed linting errors in sequence directory

* fixed linting errors in io directory

* removed repeated dictionary key in diversity directory

* fixed type comparison in alignment directory

* fixed second repeated key literal in diversity directory
  • Loading branch information
mataton authored Jan 29, 2024
1 parent a535d5e commit 2708578
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 9 deletions.
2 changes: 1 addition & 1 deletion skbio/alignment/tests/test_ssw.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def _check_bit_flag_sets_properties_falsy_or_negative(
kwarg = {}

def falsy_or_negative(alignment, prop):
if type(alignment[prop]) is int:
if isinstance(alignment[prop], int):
return alignment[prop] < 0
else:
return not alignment[prop]
Expand Down
2 changes: 0 additions & 2 deletions skbio/diversity/alpha/_lladser.py
Original file line number Diff line number Diff line change
Expand Up @@ -426,8 +426,6 @@ def _ul_confidence_bounds(f, r, alpha):
(6, 6, 0.95): (1.8207383, 2.58658608),
(5, 7, 0.95): (2.48303930, 3.22806682),
(3, 14, 0.95): (7.17185045, 8.27008349),
(2.5, 19, 0.95): (11.26109001, 11.96814857),
(1.5, 94, 0.95): (75.9077267, 76.5492088),
(1.25, 309, 0.95): (275.661191, 275.949782)
}

Expand Down
4 changes: 2 additions & 2 deletions skbio/io/format/gff3.py
Original file line number Diff line number Diff line change
Expand Up @@ -359,9 +359,9 @@ def _interval_metadata_to_gff3(obj, fh, seq_id, skip_subregion=True):

def _construct_seq(fh, constructor=DNA, seq_num=1):
lines = []
for i, (data_type, seq_id, l) in enumerate(_yield_record(fh), 1):
for i, (data_type, seq_id, L) in enumerate(_yield_record(fh), 1):
if data_type == 'data' and seq_num == i:
lines = l
lines = L
seq = _get_nth_sequence(_fasta_to_generator(fh, constructor=constructor),
seq_num=seq_num)
seq.interval_metadata = _parse_record(lines, len(seq))
Expand Down
2 changes: 1 addition & 1 deletion skbio/io/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -887,7 +887,7 @@ def sniffer(self, override=False):
(False, {})
"""
if not type(override) is bool:
if isinstance(override, bool) is not True:
raise InvalidRegistrationError("`override` must be a bool not %r"
% override)

Expand Down
6 changes: 3 additions & 3 deletions skbio/sequence/_sequence.py
Original file line number Diff line number Diff line change
Expand Up @@ -648,7 +648,7 @@ def __init__(self, sequence, metadata=None, positional_metadata=None,
self._convert_to_uppercase(lowercase_mask)

# If it isn't True, it must be a string_type
if not (lowercase is True):
if lowercase is not True:
self.positional_metadata[lowercase] = lowercase_mask
else:
raise TypeError("lowercase keyword argument expected a bool or "
Expand Down Expand Up @@ -1414,7 +1414,7 @@ def replace(self, where, character):
True
"""
if type(character) is not bytes:
if isinstance(character, bytes) is not True:
character = character.encode('ascii')
character = ord(character)
index = self._munge_to_index_array(where)
Expand Down Expand Up @@ -2179,7 +2179,7 @@ def _munge_to_sequence(self, other, method):
return Sequence(other)

def _munge_to_bytestring(self, other, method):
if type(other) is bytes:
if isinstance(other, bytes):
return other
elif isinstance(other, str):
return other.encode('ascii')
Expand Down

0 comments on commit 2708578

Please sign in to comment.