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

Add support for named tuples to pretty #2031

Merged
merged 9 commits into from
Mar 8, 2022
Merged

Conversation

darrenburns
Copy link
Member

@darrenburns darrenburns commented Mar 7, 2022

Type of changes

  • Bug fix
  • New feature
  • Documentation / docstrings
  • Tests
  • Other

Checklist

  • I've run the latest black with default args on new code.
  • I've updated CHANGELOG.md and CONTRIBUTORS.md where appropriate.
  • I've added tests for new code.
  • I accept that @willmcgugan may be pedantic in the code review.

Description

Closes #2012

Named tuples will be formatted similarly to dataclasses when formatted using the pretty module. The code for handling this is very similar to dataclasses, but I opted not to try and factor it out as I think it will reduce readability.

@codecov-commenter
Copy link

codecov-commenter commented Mar 7, 2022

Codecov Report

Merging #2031 (709b6d3) into master (75f4637) will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #2031   +/-   ##
=======================================
  Coverage   99.81%   99.81%           
=======================================
  Files          71       71           
  Lines        7058     7088   +30     
=======================================
+ Hits         7045     7075   +30     
  Misses         13       13           
Flag Coverage Δ
unittests 99.81% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
rich/pretty.py 99.73% <100.00%> (+0.02%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update aa4546a...709b6d3. Read the comment docs.

@darrenburns darrenburns marked this pull request as ready for review March 7, 2022 13:35
Copy link
Collaborator

@willmcgugan willmcgugan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mainly just detecting if __repr__ has been overriden.

rich/pretty.py Outdated Show resolved Hide resolved
rich/pretty.py Show resolved Hide resolved
Copy link
Collaborator

@willmcgugan willmcgugan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Introspection is tricky

rich/pretty.py Outdated Show resolved Hide resolved
rich/pretty.py Outdated Show resolved Hide resolved
rich/pretty.py Outdated Show resolved Hide resolved
rich/pretty.py Outdated Show resolved Hide resolved
rich/pretty.py Outdated Show resolved Hide resolved
@darrenburns
Copy link
Member Author

Sorry about that - should be ready for another round now @willmcgugan

Copy link
Collaborator

@willmcgugan willmcgugan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

rich/pretty.py Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[REQUEST] Add explicit support for NamedTuples
3 participants