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 --outdir to pass a str to webbrowser.open_new_tab() #171

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

hugovk
Copy link

@hugovk hugovk commented Aug 6, 2024

❯ python --version
Python 3.12.4
❯ python -X importtime -c 'import pprint' 2> import.log && tuna import.log -o /tmp/tuna-html
Exception in thread Thread-1 (<lambda>):
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/threading.py", line 1073, in _bootstrap_inner
    self.run()
  File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/threading.py", line 1010, in run
    self._target(*self._args, **self._kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/tuna/cli.py", line 29, in <lambda>
    target=lambda: webbrowser.open_new_tab(outdir / "index.html")
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/webbrowser.py", line 103, in open_new_tab
    return open(url, 2)
           ^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/webbrowser.py", line 87, in open
    if browser.open(url, new, autoraise):
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/webbrowser.py", line 639, in open
    script = 'open location "%s"' % url.replace('"', '%22') # opens in default browser
                                    ^^^^^^^^^^^^^^^^^^^^^^^
TypeError: Path.replace() takes 2 positional arguments but 3 were given

This is because webbrowser.open_new_tab(url) expects url to be a str, not a pathlib.Path.

Also remove some redundant parentheses.

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.

1 participant