Skip to content

Fix use of is and is not vs. == #634

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

Merged
merged 1 commit into from
Apr 30, 2025
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 polymorphic/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def __new__(self, model_name, bases, attrs, **kwargs):
# determine the name of the primary key field and store it into the class variable
# polymorphic_primary_key_name (it is needed by query.py)
for f in new_class._meta.fields:
if f.primary_key and type(f) != models.OneToOneField:
if f.primary_key and type(f) is not models.OneToOneField:
new_class.polymorphic_primary_key_name = f.name
break

Expand Down
2 changes: 1 addition & 1 deletion polymorphic/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ def tree_node_test___lookup(my_model, node):
for i in range(len(node.children)):
child = node.children[i]

if type(child) == tuple:
if type(child) is tuple:
# this Q object child is a tuple => a kwarg like Q( instance_of=ModelB )
assert "___" not in child[0], ___lookup_assert_msg
else:
Expand Down
2 changes: 1 addition & 1 deletion polymorphic/showfields.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def _showfields_add_regular_fields(self, parts):
out = field.name

# if this is the standard primary key named "id", print it as we did with older versions of django_polymorphic
if field.primary_key and field.name == "id" and type(field) == models.AutoField:
if field.primary_key and field.name == "id" and type(field) is models.AutoField:
out += f" {getattr(self, field.name)}"

# otherwise, display it just like all other fields (with correct type, shortened content etc.)
Expand Down