Skip to content

Commit

Permalink
disable pylint error E0202 for JSON encoding
Browse files Browse the repository at this point in the history
We need to override the json.JSONEncoder default() method, but pylint
sees this as an error - even though it's the documented approach.

See here for other complaints: pylint-dev/pylint#414

See here for justification: https://docs.python.org/3/library/json.html
  • Loading branch information
widdowquinn committed Jun 5, 2019
1 parent 0327590 commit 0c40ea7
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions diagnostic_primers/primersearch.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def build_commands(
# command will give a non-zero exit code, and fail tests. In this
# instance we write a blank primersearch "output file" and don't
# append the command-line to the list which will be returned.
if len(primers) == 0:
if not primers:
with open(outstem, "w") as ofh:
ofh.write("")
elif not os.path.split(outstem)[-1] in existingfiles:
Expand Down Expand Up @@ -218,7 +218,7 @@ def __str__(self):
class AmplimersEncoder(json.JSONEncoder):
"""JSON encoder for PrimerSearchAmplimer objects."""

def default(self, obj):
def default(self, obj): # pylint: disable=E0202
if not isinstance(obj, PrimerSearchAmplimer):
return json.JSONEncoder.default(self, obj)

Expand Down Expand Up @@ -345,7 +345,7 @@ class PDPGenomeAmpliconsEncoder(json.JSONEncoder):

"""JSON encoder for PDPGenomeAmplicons objects"""

def default(self, obj):
def default(self, obj): # pylint: disable=E0202
if isinstance(obj, PrimerSearchAmplimer):
encoder = AmplimersEncoder()
return encoder.default(obj)
Expand Down

0 comments on commit 0c40ea7

Please sign in to comment.