Skip to content

Commit

Permalink
Fix some minor linting issues
Browse files Browse the repository at this point in the history
  • Loading branch information
dan-blanchard committed Dec 11, 2020
1 parent 1abe748 commit d717c42
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 13 deletions.
4 changes: 2 additions & 2 deletions chardet/charsetprober.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ def reset(self):
def charset_name(self):
return None

def feed(self, buf):
pass
def feed(self, byte_str):
raise NotImplementedError

@property
def state(self):
Expand Down
16 changes: 5 additions & 11 deletions chardet/utf1632prober.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
######################## BEGIN LICENSE BLOCK ########################
# The Original Code is mozilla.org code.
#
# The Initial Developer of the Original Code is
# Netscape Communications Corporation.
# Portions created by the Initial Developer are Copyright (C) 1998
# the Initial Developer. All Rights Reserved.
#
# Contributor(s):
# Jason Zavaglia
Expand All @@ -24,9 +18,8 @@
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
# 02110-1301 USA
######################### END LICENSE BLOCK #########################
from chardet.enums import ProbingState

from .charsetprober import CharSetProber
from .enums import ProbingState


class UTF1632Prober(CharSetProber):
Expand Down Expand Up @@ -202,13 +195,14 @@ def feed(self, byte_str):
else:
self.nonzeros_at_mod[mod4] += 1
self.position += 1
return self.state()
return self.state

@property
def state(self):
if self._state in [ProbingState.NOT_ME, ProbingState.FOUND_IT]:
if self._state in {ProbingState.NOT_ME, ProbingState.FOUND_IT}:
# terminal, decided states
return self._state
elif self.get_confidence() > 0.80:
if self.get_confidence() > 0.80:
self._state = ProbingState.FOUND_IT
elif self.position > 4 * 1024:
# if we get to 4kb into the file, and we can't conclude it's UTF,
Expand Down

0 comments on commit d717c42

Please sign in to comment.