Skip to content

Commit

Permalink
Do not compare types, use isinstance()
Browse files Browse the repository at this point in the history
  • Loading branch information
VirginiaDooley committed Aug 21, 2023
1 parent 7301c70 commit b13dc00
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion ynr/apps/api/templatetags/api_docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def link_to_definition(value, version_and_label="next"):
ref_id = None
if type(value) in (SchemaRef, dict):
ref_id = value["$ref"].split("/")[-1]
if type(value) == tuple:
if isinstance(value, tuple):
ref_id = value[1]
if isinstance(value, str):
ref_id = value
Expand Down
2 changes: 1 addition & 1 deletion ynr/apps/parties/api/next/api_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def get(self, request, *args, **kwargs):
for party in qs:
item = {}

if type(party[1]) == list:
if isinstance(party[1], list):
# This is a party with descriptions
item["text"] = party[0]
item["children"] = []
Expand Down
2 changes: 1 addition & 1 deletion ynr/apps/people/forms/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ class BlankApproximateDateFormField(ApproximateDateFormField):
"""

def clean(self, value):
if type(value) == str:
if isinstance(value, str):
value = value.replace("-00", "-01")
value = super().clean(value)
if not value:
Expand Down
2 changes: 1 addition & 1 deletion ynr/apps/resultsbot/importers/modgov.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class ModGovCandidate(BaseCandidate):
def __init__(self, candidate_xml, division):
self.division = division
self.xml = candidate_xml
if type(candidate_xml) == str:
if isinstance(candidate_xml, str):
self.soup = BeautifulSoup(self.xml, "xml")
else:
self.soup = candidate_xml
Expand Down
2 changes: 1 addition & 1 deletion ynr/apps/utils/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class SelectWithAttrs(Select):
def create_option(
self, name, value, label, selected, index, subindex=None, attrs=None
):
if type(label) == dict:
if isinstance(label, dict):
label = dict(label)
label_text = label.pop("label")
else:
Expand Down

0 comments on commit b13dc00

Please sign in to comment.