# Discussions and Pull Requests

## Interacting with Discussions and Pull Requests

Check the [HfApi](https://huggingface.co/docs/huggingface_hub/v0.18.0.rc0/en/package_reference/hf_api#huggingface_hub.HfApi) documentation page for the reference of methods enabling interaction with Pull Requests and Discussions on the Hub.

* [get\_repo\_discussions()](https://huggingface.co/docs/huggingface_hub/v0.18.0.rc0/en/package_reference/hf_api#huggingface_hub.HfApi.get_repo_discussions)
* [get\_discussion\_details()](https://huggingface.co/docs/huggingface_hub/v0.18.0.rc0/en/package_reference/hf_api#huggingface_hub.HfApi.get_discussion_details)
* [create\_discussion()](https://huggingface.co/docs/huggingface_hub/v0.18.0.rc0/en/package_reference/hf_api#huggingface_hub.HfApi.create_discussion)
* [create\_pull\_request()](https://huggingface.co/docs/huggingface_hub/v0.18.0.rc0/en/package_reference/hf_api#huggingface_hub.HfApi.create_pull_request)
* [rename\_discussion()](https://huggingface.co/docs/huggingface_hub/v0.18.0.rc0/en/package_reference/hf_api#huggingface_hub.HfApi.rename_discussion)
* [comment\_discussion()](https://huggingface.co/docs/huggingface_hub/v0.18.0.rc0/en/package_reference/hf_api#huggingface_hub.HfApi.comment_discussion)
* [edit\_discussion\_comment()](https://huggingface.co/docs/huggingface_hub/v0.18.0.rc0/en/package_reference/hf_api#huggingface_hub.HfApi.edit_discussion_comment)
* [change\_discussion\_status()](https://huggingface.co/docs/huggingface_hub/v0.18.0.rc0/en/package_reference/hf_api#huggingface_hub.HfApi.change_discussion_status)
* [merge\_pull\_request()](https://huggingface.co/docs/huggingface_hub/v0.18.0.rc0/en/package_reference/hf_api#huggingface_hub.HfApi.merge_pull_request)

### Data structures

#### class huggingface\_hub.Discussion

[\<source>](https://github.com/huggingface/huggingface_hub/blob/v0.18.0.rc0/src/huggingface_hub/community.py#L19)

( title: strstatus: typing.Literal\['open', 'closed', 'merged', 'draft']num: intrepo\_id: strrepo\_type: strauthor: stris\_pull\_request: boolcreated\_at: datetimeendpoint: str )

Parameters

* **title** (`str`) — The title of the Discussion / Pull Request
* **status** (`str`) — The status of the Discussion / Pull Request. It must be one of:
  * `"open"`
  * `"closed"`
  * `"merged"` (only for Pull Requests )
  * `"draft"` (only for Pull Requests )
* **num** (`int`) — The number of the Discussion / Pull Request.
* **repo\_id** (`str`) — The id (`"{namespace}/{repo_name}"`) of the repo on which the Discussion / Pull Request was open.
* **repo\_type** (`str`) — The type of the repo on which the Discussion / Pull Request was open. Possible values are: `"model"`, `"dataset"`, `"space"`.
* **author** (`str`) — The username of the Discussion / Pull Request author. Can be `"deleted"` if the user has been deleted since.
* **is\_pull\_request** (`bool`) — Whether or not this is a Pull Request.
* **created\_at** (`datetime`) — The `datetime` of creation of the Discussion / Pull Request.
* **endpoint** (`str`) — Endpoint of the Hub. Default is [https://huggingface.co](https://huggingface.co/).
* **git\_reference** (`str`, *optional*) — (property) Git reference to which changes can be pushed if this is a Pull Request, `None` otherwise.
* **url** (`str`) — (property) URL of the discussion on the Hub.

A Discussion or Pull Request on the Hub.

This dataclass is not intended to be instantiated directly.

#### class huggingface\_hub.DiscussionWithDetails

[\<source>](https://github.com/huggingface/huggingface_hub/blob/v0.18.0.rc0/src/huggingface_hub/community.py#L87)

( title: strstatus: typing.Literal\['open', 'closed', 'merged', 'draft']num: intrepo\_id: strrepo\_type: strauthor: stris\_pull\_request: boolcreated\_at: datetimeendpoint: strevents: typing.List\[ForwardRef('DiscussionEvent')]conflicting\_files: typing.Optional\[typing.List\[str]]target\_branch: typing.Optional\[str]merge\_commit\_oid: typing.Optional\[str]diff: typing.Optional\[str] )

Parameters

* **title** (`str`) — The title of the Discussion / Pull Request
* **status** (`str`) — The status of the Discussion / Pull Request. It can be one of:
  * `"open"`
  * `"closed"`
  * `"merged"` (only for Pull Requests )
  * `"draft"` (only for Pull Requests )
* **num** (`int`) — The number of the Discussion / Pull Request.
* **repo\_id** (`str`) — The id (`"{namespace}/{repo_name}"`) of the repo on which the Discussion / Pull Request was open.
* **repo\_type** (`str`) — The type of the repo on which the Discussion / Pull Request was open. Possible values are: `"model"`, `"dataset"`, `"space"`.
* **author** (`str`) — The username of the Discussion / Pull Request author. Can be `"deleted"` if the user has been deleted since.
* **is\_pull\_request** (`bool`) — Whether or not this is a Pull Request.
* **created\_at** (`datetime`) — The `datetime` of creation of the Discussion / Pull Request.
* **events** (`list` of [DiscussionEvent](https://huggingface.co/docs/huggingface_hub/v0.18.0.rc0/en/package_reference/community#huggingface_hub.DiscussionEvent)) — The list of `DiscussionEvents` in this Discussion or Pull Request.
* **conflicting\_files** (`list` of `str`, *optional*) — A list of conflicting files if this is a Pull Request. `None` if `self.is_pull_request` is `False`.
* **target\_branch** (`str`, *optional*) — The branch into which changes are to be merged if this is a Pull Request . `None` if `self.is_pull_request` is `False`.
* **merge\_commit\_oid** (`str`, *optional*) — If this is a merged Pull Request , this is set to the OID / SHA of the merge commit, `None` otherwise.
* **diff** (`str`, *optional*) — The git diff if this is a Pull Request , `None` otherwise.
* **endpoint** (`str`) — Endpoint of the Hub. Default is [https://huggingface.co](https://huggingface.co/).
* **git\_reference** (`str`, *optional*) — (property) Git reference to which changes can be pushed if this is a Pull Request, `None` otherwise.
* **url** (`str`) — (property) URL of the discussion on the Hub.

Subclass of [Discussion](https://huggingface.co/docs/huggingface_hub/v0.18.0.rc0/en/package_reference/community#huggingface_hub.Discussion).

#### class huggingface\_hub.DiscussionEvent

[\<source>](https://github.com/huggingface/huggingface_hub/blob/v0.18.0.rc0/src/huggingface_hub/community.py#L145)

( id: strtype: strcreated\_at: datetimeauthor: str\_event: dict )

Parameters

* **id** (`str`) — The ID of the event. An hexadecimal string.
* **type** (`str`) — The type of the event.
* **created\_at** (`datetime`) — A [`datetime`](https://docs.python.org/3/library/datetime.html?highlight=datetime#datetime.datetime) object holding the creation timestamp for the event.
* **author** (`str`) — The username of the Discussion / Pull Request author. Can be `"deleted"` if the user has been deleted since.

An event in a Discussion or Pull Request.

Use concrete classes:

* [DiscussionComment](https://huggingface.co/docs/huggingface_hub/v0.18.0.rc0/en/package_reference/community#huggingface_hub.DiscussionComment)
* [DiscussionStatusChange](https://huggingface.co/docs/huggingface_hub/v0.18.0.rc0/en/package_reference/community#huggingface_hub.DiscussionStatusChange)
* [DiscussionCommit](https://huggingface.co/docs/huggingface_hub/v0.18.0.rc0/en/package_reference/community#huggingface_hub.DiscussionCommit)
* [DiscussionTitleChange](https://huggingface.co/docs/huggingface_hub/v0.18.0.rc0/en/package_reference/community#huggingface_hub.DiscussionTitleChange)

#### class huggingface\_hub.DiscussionComment

[\<source>](https://github.com/huggingface/huggingface_hub/blob/v0.18.0.rc0/src/huggingface_hub/community.py#L178)

( id: strtype: strcreated\_at: datetimeauthor: str\_event: dictcontent: stredited: boolhidden: bool )

Parameters

* **id** (`str`) — The ID of the event. An hexadecimal string.
* **type** (`str`) — The type of the event.
* **created\_at** (`datetime`) — A [`datetime`](https://docs.python.org/3/library/datetime.html?highlight=datetime#datetime.datetime) object holding the creation timestamp for the event.
* **author** (`str`) — The username of the Discussion / Pull Request author. Can be `"deleted"` if the user has been deleted since.
* **content** (`str`) — The raw markdown content of the comment. Mentions, links and images are not rendered.
* **edited** (`bool`) — Whether or not this comment has been edited.
* **hidden** (`bool`) — Whether or not this comment has been hidden.

A comment in a Discussion / Pull Request.

Subclass of [DiscussionEvent](https://huggingface.co/docs/huggingface_hub/v0.18.0.rc0/en/package_reference/community#huggingface_hub.DiscussionEvent).

#### class huggingface\_hub.DiscussionStatusChange

[\<source>](https://github.com/huggingface/huggingface_hub/blob/v0.18.0.rc0/src/huggingface_hub/community.py#L233)

( id: strtype: strcreated\_at: datetimeauthor: str\_event: dictnew\_status: str )

Parameters

* **id** (`str`) — The ID of the event. An hexadecimal string.
* **type** (`str`) — The type of the event.
* **created\_at** (`datetime`) — A [`datetime`](https://docs.python.org/3/library/datetime.html?highlight=datetime#datetime.datetime) object holding the creation timestamp for the event.
* **author** (`str`) — The username of the Discussion / Pull Request author. Can be `"deleted"` if the user has been deleted since.
* **new\_status** (`str`) — The status of the Discussion / Pull Request after the change. It can be one of:
  * `"open"`
  * `"closed"`
  * `"merged"` (only for Pull Requests )

A change of status in a Discussion / Pull Request.

Subclass of [DiscussionEvent](https://huggingface.co/docs/huggingface_hub/v0.18.0.rc0/en/package_reference/community#huggingface_hub.DiscussionEvent).

#### class huggingface\_hub.DiscussionCommit

[\<source>](https://github.com/huggingface/huggingface_hub/blob/v0.18.0.rc0/src/huggingface_hub/community.py#L261)

( id: strtype: strcreated\_at: datetimeauthor: str\_event: dictsummary: stroid: str )

Parameters

* **id** (`str`) — The ID of the event. An hexadecimal string.
* **type** (`str`) — The type of the event.
* **created\_at** (`datetime`) — A [`datetime`](https://docs.python.org/3/library/datetime.html?highlight=datetime#datetime.datetime) object holding the creation timestamp for the event.
* **author** (`str`) — The username of the Discussion / Pull Request author. Can be `"deleted"` if the user has been deleted since.
* **summary** (`str`) — The summary of the commit.
* **oid** (`str`) — The OID / SHA of the commit, as a hexadecimal string.

A commit in a Pull Request.

Subclass of [DiscussionEvent](https://huggingface.co/docs/huggingface_hub/v0.18.0.rc0/en/package_reference/community#huggingface_hub.DiscussionEvent).

#### class huggingface\_hub.DiscussionTitleChange

[\<source>](https://github.com/huggingface/huggingface_hub/blob/v0.18.0.rc0/src/huggingface_hub/community.py#L288)

( id: strtype: strcreated\_at: datetimeauthor: str\_event: dictold\_title: strnew\_title: str )

Parameters

* **id** (`str`) — The ID of the event. An hexadecimal string.
* **type** (`str`) — The type of the event.
* **created\_at** (`datetime`) — A [`datetime`](https://docs.python.org/3/library/datetime.html?highlight=datetime#datetime.datetime) object holding the creation timestamp for the event.
* **author** (`str`) — The username of the Discussion / Pull Request author. Can be `"deleted"` if the user has been deleted since.
* **old\_title** (`str`) — The previous title for the Discussion / Pull Request.
* **new\_title** (`str`) — The new title.

A rename event in a Discussion / Pull Request.

Subclass of [DiscussionEvent](https://huggingface.co/docs/huggingface_hub/v0.18.0.rc0/en/package_reference/community#huggingface_hub.DiscussionEvent).
