Skip to content

Conversation

@darrenburns
Copy link
Member

@darrenburns darrenburns commented Mar 8, 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

Objects defined in a REPL are part of the __main__ scope, which doesn't have a corresponding file, and so rich.inspect was failing when trying to find this filename.

inspect.getfile raises an OSError in this case.

We catch the OSError and ignore it, as the rest of the code already handles the case where there is no source_filename available.

Closes #2033

@codecov-commenter
Copy link

codecov-commenter commented Mar 8, 2022

Codecov Report

Merging #2037 (38aa939) into master (75f4637) will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #2037   +/-   ##
=======================================
  Coverage   99.81%   99.81%           
=======================================
  Files          71       71           
  Lines        7058     7058           
=======================================
  Hits         7045     7045           
  Misses         13       13           
Flag Coverage Δ
unittests 99.81% <100.00%> (ø)

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

Impacted Files Coverage Δ
rich/__init__.py 100.00% <100.00%> (ø)
rich/_inspect.py 100.00% <100.00%> (ø)

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 8e649fe...38aa939. Read the comment docs.

@darrenburns darrenburns requested a review from willmcgugan March 8, 2022 14:13
Copy link
Member

@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.

That was simple :)

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.

[BUG] Inspecting a NamedTuple defined int the REPL throws an error

4 participants