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
Add __repr__ methods #382
Add __repr__ methods #382
Conversation
I’m generally in favor of this. Any objection to using format() instead of %? Also style wise I prefer skipping the multi line string, then making the argument list one argument per line as it’s easier to scan. |
You mean like def __repr__(self):
- return ('Plan(pk=%r, name=%r, amount=%r, currency=%r, interval=%r, '
- 'interval_count=%r, trial_period_days=%r, stripe_id=%r)' % (
- self.pk, self.name, self.amount, self.currency,
- self.interval, self.interval_count,
- self.trial_period_days, self.stripe_id))
+ return ('Plan(pk={!r}, name={!r}, amount={!r}, currency={!r}, interval={!r}, '
+ 'interval_count={!r}, trial_period_days={!r}, stripe_id={!r})'.format(
+ self.pk,
+ self.name,
+ self.amount,
+ self.currency,
+ self.interval,
+ self.interval_count,
+ self.trial_period_days,
+ self.stripe_id)) ? IMHO it makes the whole file harder to scan (by adding more lines). |
@paltman |
No, more like: def __repr__(self):
return "Plan(pk={!r}, name={!r}, amount={!r}, currency={!r}, interval={!r}, interval_count={!r}, trial_period_days={!r}, stripe_id={!r})".format(
self.pk,
self.name,
self.amount,
self.currency,
self.interval,
self.interval_count,
self.trial_period_days,
self.stripe_id
) |
fa34aec
to
3431bfc
Compare
Amended and added basic tests. |
Hit by string string differences in py2 and py3 on the tests. |
How to handle this best?
|
Codecov Report
@@ Coverage Diff @@
## master #382 +/- ##
==========================================
+ Coverage 99.39% 99.39% +<.01%
==========================================
Files 34 34
Lines 1651 1662 +11
Branches 134 135 +1
==========================================
+ Hits 1641 1652 +11
Misses 5 5
Partials 5 5
Continue to review full report at Codecov.
|
This applies the python_2_unicode_compatible decorator to all models through the base StripeObject. Helps with pinax#382.
This applies the python_2_unicode_compatible decorator to all models through the base StripeObject. Helps with pinax#382.
This is only done for Plan, Customer and Subscription for now, and open for discussion. It helps a lot when debugging and/or looking at locals in tracebacks.
This is really helpul while debugging btw! |
This is only done for Plan, Customer and Subscription for now, and open
for discussion.
It helps a lot when debugging and/or looking at locals in tracebacks.
TODO: