Skip to content

Commit 43973f9

Browse files
committed
some pylint changes- super(), class without object, elif after return
1 parent f062157 commit 43973f9

File tree

7 files changed

+14
-14
lines changed

7 files changed

+14
-14
lines changed

.pylintrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ expected-line-ending-format=
134134
bad-functions=map,filter
135135

136136
# Good variable names which should always be accepted, separated by a comma
137-
good-names=i,j,k,b,f,v,m,n,p,hh,st,ex,Run,_
137+
good-names=i,j,k,b,f,v,m,n,p,d,hh,st,ex,Run,_
138138

139139
# Bad variable names which should always be refused, separated by a comma
140140
bad-names=foo,bar,baz,toto,tutu,tata

probables/blooms/bloom.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def _verify_not_type_mismatch(second: SimpleBloomT) -> bool:
3030
return isinstance(second, (BloomFilter, BloomFilterOnDisk))
3131

3232

33-
class BloomFilter(object):
33+
class BloomFilter:
3434
"""Simple Bloom Filter implementation for use in python; It can read and write the
3535
same format as the c version (https://github.com/barrust/bloom)
3636
@@ -610,7 +610,7 @@ def __init__(
610610
if is_hex_string(hex_string):
611611
msg = "Loading from hex_string is currently not supported by the on disk Bloom Filter"
612612
raise NotSupportedError(msg)
613-
elif est_elements is not None and false_positive_rate is not None:
613+
if est_elements is not None and false_positive_rate is not None:
614614
fpr, n_hashes, n_bits = self._get_optimized_params(est_elements, false_positive_rate)
615615
self._set_values(est_elements, fpr, n_hashes, n_bits, hash_function)
616616

@@ -668,7 +668,7 @@ def _load(self, filepath: Union[str, Path], hash_function: Union[HashFuncT, None
668668
self._on_disk = True
669669

670670
def add_alt(self, hashes: HashResultsT) -> None:
671-
super(BloomFilterOnDisk, self).add_alt(hashes)
671+
super().add_alt(hashes)
672672
self.__update()
673673

674674
@classmethod

probables/blooms/expandingbloom.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ def __init__(
276276
hash_function: Union[HashFuncT, None] = None,
277277
) -> None:
278278
"""initialize"""
279-
super(RotatingBloomFilter, self).__init__(
279+
super().__init__(
280280
est_elements=est_elements,
281281
false_positive_rate=false_positive_rate,
282282
filepath=filepath,

probables/countminsketch/countminsketch.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
from ..utilities import MMap, is_valid_file
2020

2121

22-
class CountMinSketch(object):
22+
class CountMinSketch:
2323
"""Simple Count-Min Sketch implementation for use in python;
2424
It can read and write the same format as the c version
2525
(https://github.com/barrust/count-min-sketch)
@@ -141,7 +141,7 @@ def __str__(self) -> str:
141141

142142
def __contains__(self, key: KeyT) -> bool:
143143
"""setup the `in` keyword"""
144-
return True if self.check(key) != 0 else False
144+
return self.check(key) != 0
145145

146146
def __bytes__(self) -> bytes:
147147
"""Export countmin-sketch to `bytes`"""

probables/cuckoo/countingcuckoo.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ def _insert_fingerprint_alt(
244244
self._inserted_elements += 1
245245
self.__unique_elements += 1
246246
return None
247-
elif self.__insert_element(fingerprint, idx_2, count):
247+
if self.__insert_element(fingerprint, idx_2, count):
248248
self._inserted_elements += 1
249249
self.__unique_elements += 1
250250
return None
@@ -277,7 +277,7 @@ def _check_if_present(self, idx_1: int, idx_2: int, fingerprint: int) -> Union[i
277277
"""wrapper for checking if fingerprint is already inserted"""
278278
if fingerprint in [x.finger for x in self.buckets[idx_1]]:
279279
return idx_1
280-
elif fingerprint in [x.finger for x in self.buckets[idx_2]]:
280+
if fingerprint in [x.finger for x in self.buckets[idx_2]]:
281281
return idx_2
282282
return None
283283

probables/cuckoo/cuckoo.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
from ..utilities import MMap, get_x_bits, is_valid_file
1919

2020

21-
class CuckooFilter(object):
21+
class CuckooFilter:
2222
"""Simple Cuckoo Filter implementation
2323
2424
Args:
@@ -366,7 +366,7 @@ def _insert_fingerprint(self, fingerprint, idx_1, idx_2):
366366
if self.__insert_element(fingerprint, idx_1):
367367
self._inserted_elements += 1
368368
return None
369-
elif self.__insert_element(fingerprint, idx_2):
369+
if self.__insert_element(fingerprint, idx_2):
370370
self._inserted_elements += 1
371371
return None
372372

@@ -444,7 +444,7 @@ def _check_if_present(self, idx_1, idx_2, fingerprint):
444444
"""wrapper for checking if fingerprint is already inserted"""
445445
if fingerprint in self.buckets[idx_1]:
446446
return idx_1
447-
elif fingerprint in self.buckets[idx_2]:
447+
if fingerprint in self.buckets[idx_2]:
448448
return idx_2
449449
return None
450450

@@ -513,7 +513,7 @@ def _deal_with_insertion(self, finger):
513513
"""some code to handle the insertion the same"""
514514
if finger is None:
515515
return
516-
elif self.auto_expand:
516+
if self.auto_expand:
517517
self._expand_logic(finger)
518518
else:
519519
msg = "The {} is currently full".format(self.__class__.__name__)

probables/utilities.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def get_x_bits(num: int, max_bits: int, num_bits: int, right_bits: bool = True)
2929
return int(bits[:num_bits], 2)
3030

3131

32-
class MMap(object):
32+
class MMap:
3333
"""Simplified mmap.mmap class"""
3434

3535
__slots__ = ("p", "__f", "m", "_closed")

0 commit comments

Comments
 (0)