Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not compare types, use isinstance() #2164

Merged
merged 2 commits into from
Aug 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ node_modules/
/test-env
/ynr/apps/sopn_parsing/tests/data/sopn_baseline.json
/ynr/apps/sopn_parsing/tests/data/sopn_baseline_copy.json

/src
# PyCharm
.idea/

Expand Down
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
Loading