Skip to content

Commit

Permalink
🐍 Remove all code with "Python 2 compat" comments
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinHock committed Mar 30, 2020
1 parent 0e1dd3f commit 05727d2
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 24 deletions.
14 changes: 2 additions & 12 deletions detect_secrets/plugins/common/ini_file_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,7 @@ def __init__(self, file, add_header=False, exclude_lines_regex=None):
:param exclude_lines_regex: optional regex for ignored lines.
"""
self.parser = configparser.ConfigParser()
try:
# Python2.7 compatible
self.parser.optionxform = unicode
except NameError: # pragma: no cover
# Python3 compatible
self.parser.optionxform = str
self.parser.optionxform = str

self.exclude_lines_regex = exclude_lines_regex

Expand All @@ -47,12 +42,7 @@ def __init__(self, file, add_header=False, exclude_lines_regex=None):
# like config files, without a section header.
content = '[global]\n' + content

try:
# Python2.7 compatible
self.parser.read_string(unicode(content))
except NameError: # pragma: no cover
# Python3 compatible
self.parser.read_string(content)
self.parser.read_string(content)

# Hacky way to keep track of line location
file.seek(0)
Expand Down
7 changes: 0 additions & 7 deletions detect_secrets/plugins/jwt.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,6 @@
from .base import classproperty
from .base import RegexBasedDetector

try:
# Python 2
from future_builtins import filter
except ImportError: # pragma: no cover
# Python 3
pass


class JwtTokenDetector(RegexBasedDetector):
"""Scans for JWTs."""
Expand Down
6 changes: 1 addition & 5 deletions testing/mocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,11 +138,7 @@ def __init__(self):
self.clear()

def add(self, message, *args, **kwargs):
try:
# For python 2.x compatible
self.message += unicode(message) + '\n'
except NameError:
self.message += str(message) + '\n'
self.message += str(message) + '\n'

def clear(self):
self.message = ''
Expand Down

0 comments on commit 05727d2

Please sign in to comment.