You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I made some recent updates to application that uses Repository.get_contents() and ran into some typing issues with a recent mypy update.
My proposal is to modify the return type of Repository.get_contents() to be List[github.ContentFile.ContentFile] instead of Union[github.ContentFile.ContentFile, List[github.ContentFile.ContentFile], None]. This would help to clean up the mypy issues and make the API clearer.
Something like this:
if isinstance(data, list):
return [
# Lazy completion only makes sense for files. See discussion
# here: https://github.com/jacquev6/PyGithub/issues/140#issuecomment-13481130
github.ContentFile.ContentFile(
self._requester, headers, item, completed=(item["type"] != "file")
)
for item in data
]
return [
github.ContentFile.ContentFile(
self._requester, headers, data, completed=True
)
]
I'm happy to open a PR with this change or discuss further. Thanks!
The text was updated successfully, but these errors were encountered:
pjames5
changed the title
Modify Repository.get_contents() to always return a List[github.ContentFile.ContentFile]
Modify Repository.get_contents() to always return List[github.ContentFile.ContentFile]
Mar 8, 2022
Hello!
I made some recent updates to application that uses
Repository.get_contents()
and ran into some typing issues with a recentmypy
update.My proposal is to modify the return type of
Repository.get_contents()
to beList[github.ContentFile.ContentFile]
instead ofUnion[github.ContentFile.ContentFile, List[github.ContentFile.ContentFile], None]
. This would help to clean up themypy
issues and make the API clearer.Something like this:
I'm happy to open a PR with this change or discuss further. Thanks!
The text was updated successfully, but these errors were encountered: