yanyongyu / githubkit

The modern, all-batteries-included GitHub SDK for Python, including rest api, graphql, webhooks, like octokit!
https://yanyongyu.github.io/githubkit/
MIT License
177 stars 25 forks source link

Bug: `pull request simple` field `head label` schema incorrect #64

Closed schelv closed 9 months ago

schelv commented 9 months ago
from githubkit import GitHub, TokenAuthStrategy

g = GitHub(TokenAuthStrategy(<token>))

params = {'page': 430, 'per_page': 100, 'sort': 'asc', 'state': 'all'}
prs = g.rest.pulls.list(owner='home-assistant', repo='core', **params)

prs.parsed_data

Gives

Traceback (most recent call last):
  File "C:\Users\username\project\test_bug.py", line 9, in <module>
    for pr in prs.parsed_data:
              ^^^^^^^^^^^^^^^
  File "C:\Users\username\project\.venv\Lib\site-packages\githubkit\response.py", line 50, in parsed_data
    return parse_raw_as(self._data_model, self._response.content)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\username\project\.venv\Lib\site-packages\pydantic\tools.py", line 82, in parse_raw_as
    return parse_obj_as(type_, obj, type_name=type_name)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\username\project\.venv\Lib\site-packages\pydantic\tools.py", line 38, in parse_obj_as
    return model_type(__root__=obj).__root__
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\username\project\.venv\Lib\site-packages\pydantic\main.py", line 341, in __init__
    raise validation_error
pydantic.error_wrappers.ValidationError: 1 validation error for ParsingModel[List[githubkit.rest.models.PullRequestSimple]]
__root__ -> 56 -> head -> label
  none is not an allowed value (type=type_error.none.not_allowed)
yanyongyu commented 9 months ago

Duplicate of #56