Skip to content

Commit

Permalink
Fix unidiomatic-typecheck
Browse files Browse the repository at this point in the history
  • Loading branch information
sergioburdisso committed Feb 26, 2020
1 parent 5dbdc3a commit b0b3eaa
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions pyss3/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,7 @@ def __get_category__(self, name):
If category name doesn't exist, creates a new one.
"""
if type(name) is str:
if isinstance(name, str):
name = name.lower()
try:
return self.__categories_index__[name]
Expand Down Expand Up @@ -1077,7 +1077,7 @@ def get_category_index(self, name):
:rtype: int
"""
try:
if type(name) is str:
if isinstance(name, str):
name = name.lower()
return self.__categories_index__[name]
except KeyError:
Expand All @@ -1094,7 +1094,7 @@ def get_category_name(self, index):
:rtype: str
"""
try:
if type(index) == list:
if isinstance(index, list):
index = index[0]
return self.__categories__[index][NAME]
except IndexError:
Expand Down
6 changes: 3 additions & 3 deletions pyss3/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -1283,10 +1283,10 @@ def kfold_cross_validation(
if not clf or not clf.__categories__:
raise EmptyModelError

if type(k) is not int or k < 2:
if not isinstance(k, int) or k < 2:
raise ValueError(ERROR_IKV)

if n_grams is not None and (type(n_grams) is not int or n_grams < 1):
if n_grams is not None and (not isinstance(n_grams, int) or n_grams < 1):
raise ValueError(ERROR_INGV)

Evaluation.set_classifier(clf)
Expand Down Expand Up @@ -1454,7 +1454,7 @@ def grid_search(
:rtype: tuple
:raises: InvalidCategoryError, EmptyModelError, ValueError, TypeError
"""
if k_fold is not None and type(k_fold) is not int:
if k_fold is not None and not isinstance(k_fold, int):
raise TypeError(ERROR_IKT)

from . import SS3
Expand Down

0 comments on commit b0b3eaa

Please sign in to comment.