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

fix: Fix implicit modules in IPython shells #662

Merged
merged 1 commit into from
Nov 25, 2024
Merged

fix: Fix implicit modules in IPython shells #662

merged 1 commit into from
Nov 25, 2024

Conversation

mark-koch
Copy link
Collaborator

Fixes #661

@mark-koch mark-koch requested a review from a team as a code owner November 25, 2024 10:34
Comment on lines +15 to +24
def is_ipython_dummy_file(filename: str) -> bool:
"""Checks whether a given filename is a dummy name generated for an IPython cell."""
# TODO: The approach below is false-positive prone. Figure out if there is a better
# way to do this.
return (
# IPython cells have filenames like "<ipython-input-3-3e9b5833de21>"
filename.startswith("<ipython-input-")
# Jupyter cells have filenames like "/var/{...}/ipykernel_82076/61218616.py"
or "ipykernel_" in filename
)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'm not really happy with this, but I don't know a better way to solve this problem :/

@codecov-commenter
Copy link

Codecov Report

Attention: Patch coverage is 75.00000% with 1 line in your changes missing coverage. Please review.

Project coverage is 92.48%. Comparing base (bb2ca83) to head (40c36b0).

Files with missing lines Patch % Lines
guppylang/ipython_inspect.py 50.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #662      +/-   ##
==========================================
- Coverage   92.49%   92.48%   -0.02%     
==========================================
  Files          66       66              
  Lines        7503     7505       +2     
==========================================
+ Hits         6940     6941       +1     
- Misses        563      564       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.


🚨 Try these New Features:

Copy link
Contributor

@cqc-alec cqc-alec left a comment

Choose a reason for hiding this comment

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

Thanks! Tested and it works.

@cqc-alec
Copy link
Contributor

(The only difference between the generated hugr when run in ipython with this fix and when run as a python script is that the Module metadata is {'name': '<jupyter-notebook>'} versus {'name': '__main__'}.)

Copy link
Member

@ss2165 ss2165 left a comment

Choose a reason for hiding this comment

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

:/

@mark-koch mark-koch added this pull request to the merge queue Nov 25, 2024
Merged via the queue into main with commit 4ecb5f2 Nov 25, 2024
3 checks passed
@mark-koch mark-koch deleted the fix/ipython branch November 25, 2024 11:34
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.

Compiled module's main function misnamed in ipython shell.
4 participants