#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 , 8 years ago
Component: | Uncategorized → Core (Other) |
---|---|
Triage Stage: | Unreviewed → Accepted |
comment:2 by , 8 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
comment:3 by , 8 years ago
Replying to Mads Jensen:
I noticed there are a few places where
__repr__
does not useself.__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:5 by , 8 years ago
Ticket will be closed when a maintainer merges the changes and marks it as solved.
Sure, while there it would be nice to add tests if missing.