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

If no GitHub URL for project an error is raised #39

Closed
ryancheley opened this issue Dec 9, 2021 · 5 comments
Closed

If no GitHub URL for project an error is raised #39

ryancheley opened this issue Dec 9, 2021 · 5 comments
Labels
bug Something isn't working
Milestone

Comments

@ryancheley
Copy link
Owner

Describe the bug
For projects that have (usually the Home Page) set to a page that is not on the GitHub.com domain you receive an UnboundLocalError

Traceback (most recent call last):
  File "/Users/ryan/Documents/github/the-well-maintained-test/venv/bin/the-well-maintained-test", line 33, in <module>
    sys.exit(load_entry_point('the-well-maintained-test', 'console_scripts', 'the-well-maintained-test')())
  File "/Users/ryan/Documents/github/the-well-maintained-test/venv/lib/python3.9/site-packages/click/core.py", line 1128, in __call__
    return self.main(*args, **kwargs)
  File "/Users/ryan/Documents/github/the-well-maintained-test/venv/lib/python3.9/site-packages/click/core.py", line 1053, in main
    rv = self.invoke(ctx)
  File "/Users/ryan/Documents/github/the-well-maintained-test/venv/lib/python3.9/site-packages/click/core.py", line 1659, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/Users/ryan/Documents/github/the-well-maintained-test/venv/lib/python3.9/site-packages/click/core.py", line 1395, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/Users/ryan/Documents/github/the-well-maintained-test/venv/lib/python3.9/site-packages/click/core.py", line 754, in invoke
    return __callback(*args, **kwargs)
  File "/Users/ryan/Documents/github/the-well-maintained-test/src/the_well_maintained_test/cli.py", line 344, in package
    if url[-1] == "/":
UnboundLocalError: local variable 'url' referenced before assignment

To Reproduce

From the command line run

the-well-maintained-test package 'healthkit-to-sqlite'

See the error get generated

For this specific package

"Homepage": "https://datasette.io/tools/healthkit-to-sqlite",

Expected behavior
The CLI can handle Home Pages not pointed at GitHub

Additional context
This issue was discovered while running the CLI on a requirements file which included the package healthkit-to-sqlite

@ryancheley ryancheley added the bug Something isn't working label Dec 9, 2021
@omerfarukabaci
Copy link

@ryancheley This issue still exists:

To Reproduce

the-well-maintained-test package unidecode

# _get_package_github_url method in helpers.py
project_urls = requests.get(url).json().get("info").get("project_urls")
for k, v in project_urls.items():
...

project_urls can be None here, and if it is an AttributeError is raised.

@ryancheley ryancheley reopened this Dec 15, 2021
@ryancheley
Copy link
Owner Author

Thanks @omerfarukabaci. I will work on a fix. The short term fix will be to just report out that there's not enough information. Something like this:

The package unidecode does not have enough information supplied by PyPi to continue.

For a more long term solution ... 🤷‍♂️yet

@omerfarukabaci
Copy link

Maybe searching a GitHub URL in PyPI description can make sense, but yeah for a quick-fix you solution seems good.

@ryancheley
Copy link
Owner Author

Using the Top PyPI Packages I determined that the top 5000 packages all have a projects_url. I think this is more of a maintainer issue than an issue for this package.

What might be best is to have a message that says something like:

This package does not have project_urls defined. You may want to contact them or raise an issue with them to include it. 

Documentation for project_urls can be found here:

https://packaging.python.org/en/latest/guides/distributing-packages-using-setuptools/#project-urls

@omerfarukabaci
Copy link

It sounds logical, thank you! 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants