Skip to content

Commit

Permalink
📝 add weakref warning
Browse files Browse the repository at this point in the history
  • Loading branch information
yanyongyu authored Jun 14, 2024
1 parent ca4c11b commit 50d6703
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,20 @@ async with GitHub("<your_token_here>") as github:
repo: FullRepository = resp.parsed_data
```

> [!WARNING]
> Note that you should hold a strong reference to the githubkit client instance. Otherwise, githubkit client will fail to call the request.
> For example, you should not do this:
>
> ```python
> from githubkit import GitHub
>
> def get_client() -> GitHub:
> return GitHub()
>
> # This will cause error
> get_client().rest.repos.get("yanyongyu", "githubkit")
> ```

### Data Validation

As shown above, the response data is parsed and validated by accessing the `response.parsed_data` property. This ensures that the data type returned by the API is as expected and your code is safe to use it (with static type checking). But sometimes you may want to get the raw data returned by the API, such as when the schema is not correct. You can use the `response.text` property or `response.json()` method to get the raw data:
Expand Down

0 comments on commit 50d6703

Please sign in to comment.