Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Stop rich.live from importing same module under a different name #912

Merged
merged 1 commit into from
Jan 13, 2021
Merged

Stop rich.live from importing same module under a different name #912

merged 1 commit into from
Jan 13, 2021

Conversation

Jackenmen
Copy link
Contributor

@Jackenmen Jackenmen commented Jan 13, 2021

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

Rich instead of importing from the top-level package using the module name alone, uses module name with __init__ which makes it get imported twice (under names: rich and rich.__init__).

Minimal reproduction:

import sys

import rich.live

print(sys.modules["rich"])
print(sys.modules["rich.__init__"])

image

I found out about it because mypy is complaining about it just because I use rich in my project. However, even if you skip that, this could still possibly lead to some strange issues when depending on the fact that modules in Python are singletons.

@codecov
Copy link

codecov bot commented Jan 13, 2021

Codecov Report

Merging #912 (9e881e5) into master (d4d087c) will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #912   +/-   ##
=======================================
  Coverage   99.54%   99.54%           
=======================================
  Files          58       58           
  Lines        5059     5059           
=======================================
  Hits         5036     5036           
  Misses         23       23           
Flag Coverage Δ
unittests 99.54% <100.00%> (ø)

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

Impacted Files Coverage Δ
rich/live.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 a1e9cc7...9e881e5. Read the comment docs.

@willmcgugan willmcgugan merged commit f84c84f into Textualize:master Jan 13, 2021
@Jackenmen Jackenmen deleted the fix_mypy_issue branch May 2, 2022 09:32
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants