Opened 8 years ago

Closed 8 years ago

Last modified 7 years ago

#27546 closed Cleanup/optimization (fixed)

Replace hardcoded class names in __repr__-methods

Reported by: Mads Jensen Owned by: Adiyat Mubarak
Component: Core (Other) Version: 1.10
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description

I noticed there are a few places where __repr__ does not use self.__class__.__name__. I think this is a small clean-up that would make sense to do, but perhaps there was a good reason not to do that (probably they're never subclassed?). The following output is from grep:

django/db/models/query.py:        return "<RawQuerySet: %s>" % self.query
django/db/models/sql/query.py:        return "<RawQuery: %s>" % self
django/db/migrations/state.py:        return "<ModelState: '%s.%s'>" % (self.app_label, self.name)
django/utils/baseconv.py:        return "<BaseConverter: base%s (%s)>" % (len(self.digits), self.digits)
django/core/management/commands/makemessages.py:        return "<TranslatableFile: %s>" % os.sep.join([self.dirpath, self.file])
django/core/serializers/base.py:        return "<DeserializedObject: %s(pk=%s)>" % (

Change History (9)

comment:1 by Tim Graham, 8 years ago

Component: UncategorizedCore (Other)
Triage Stage: UnreviewedAccepted

Sure, while there it would be nice to add tests if missing.

comment:2 by Adiyat Mubarak, 8 years ago

Owner: changed from nobody to Adiyat Mubarak
Status: newassigned

in reply to:  description comment:3 by Adiyat Mubarak, 8 years ago

Replying to Mads Jensen:

I noticed there are a few places where __repr__ does not use self.__class__.__name__. I think this is a small clean-up that would make sense to do, but perhaps there was a good reason not to do that (probably they're never subclassed?). The following output is from grep:

django/db/models/query.py:        return "<RawQuerySet: %s>" % self.query
django/db/models/sql/query.py:        return "<RawQuery: %s>" % self
django/db/migrations/state.py:        return "<ModelState: '%s.%s'>" % (self.app_label, self.name)
django/utils/baseconv.py:        return "<BaseConverter: base%s (%s)>" % (len(self.digits), self.digits)
django/core/management/commands/makemessages.py:        return "<TranslatableFile: %s>" % os.sep.join([self.dirpath, self.file])
django/core/serializers/base.py:        return "<DeserializedObject: %s(pk=%s)>" % (

Hi, I just learn to contribute on django project by taking this easy task on this PR
Do I need to update this ticket to resolve as fixed? or this ticket will closed automatically?

Thank in advance

comment:4 by Adiyat Mubarak, 8 years ago

Has patch: set

comment:5 by Mads Jensen, 8 years ago

Ticket will be closed when a maintainer merges the changes and marks it as solved.

comment:6 by Tim Graham <timograham@…>, 8 years ago

In 794b7d80:

Refs #27546 -- Tested some repr() methods.

comment:7 by Tim Graham <timograham@…>, 8 years ago

Resolution: fixed
Status: assignedclosed

In 48826aa:

Fixed #27546 -- Removed hardcoded class names in repr() methods.

comment:8 by Tim Graham <timograham@…>, 8 years ago

In 86ae1d51:

Refs #27546 -- Removed hardcoded class names in repr() methods.

comment:9 by Tim Graham <timograham@…>, 7 years ago

In ee7ab1b6:

Refs #27546 -- Replaced hardcoded class name in ForNode.repr().

Note: See TracTickets for help on using tickets.
Back to Top