wL iM0`dZddlmZddlmZddlmZmZmZmZm Z ddl m Z ddl m Z edZeGd d ZeGd d eZGd deZeGddZeGddeZeGddeZeGddeZeGddeZdedefdZy)a Data structures to interact with Discussions and Pull Requests on the Hub. See [the Discussions and Pull Requests guide](https://huggingface.co/docs/hub/repositories-pull-requests-discussions) for more information on Pull Requests, Discussions, and the community tab. ) dataclass)datetime)ListLiteralOptional TypedDictUnion) constants)parse_datetime)openclosedmergeddraftceZdZUdZeed<eed<eed<eed<eed<eed<eed<e ed <eed <e d e efd Z e d efd Z y) Discussiona A Discussion or Pull Request on the Hub. This dataclass is not intended to be instantiated directly. Attributes: 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. 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. titlestatusnumrepo_id repo_typeauthoris_pull_request created_atendpointreturnc:|jrd|jSy)z If this is a Pull Request , returns the git reference to which changes can be pushed. Returns `None` otherwise. zrefs/pr/N)rrselfs _/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/huggingface_hub/community.py git_referencezDiscussion.git_referenceEs!   dhhZ( (c|j|jtjk(r(|jd|jd|j S|jd|jd|jd|j S)z-Returns the URL of the discussion on the Hub./z /discussions/zs/)rr REPO_TYPE_MODELrrrrs r urlzDiscussion.urlOsp >> !T^^y7P7P%Pmm_Adll^= K K--$..!1DLL>txxjYYr"N)__name__ __module__ __qualname____doc__str__annotations__DiscussionStatusintboolrpropertyrr!r&r"r rrsu$L J  H LN KM x}ZSZZr"rcneZdZUdZeded<eeeedfed<e eed<e eed<e eed<y) DiscussionWithDetailsa7 Subclass of [`Discussion`]. Attributes: 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`]) The list of [`DiscussionEvents`] in this Discussion or Pull Request. conflicting_files (`Union[List[str], bool, None]`, *optional*): A list of conflicting files if this is a Pull Request. `None` if `self.is_pull_request` is `False`. `True` if there are conflicting files but the list can't be retrieved. 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. 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. DiscussionEventeventsNconflicting_files target_branchmerge_commit_oiddiff) r'r(r)r*rr,r r+r/rr1r"r r3r3WsJ0d " ##T#Yd233C= sm# 3-r"r3c@eZdZUeed<eed<eed<eed<eed<y)DiscussionEventArgsidtyperr_eventN)r'r(r)r+r,rdictr1r"r r;r;s G I K Lr"r;cDeZdZUdZeed<eed<eed<eed<eed<y)r4a An event in a Discussion or Pull Request. Use concrete classes: * [`DiscussionComment`] * [`DiscussionStatusChange`] * [`DiscussionCommit`] * [`DiscussionTitleChange`] Attributes: 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. r<r=rrr>N)r'r(r)r*r+r,rr?r1r"r r4r4s&, G I K LMr"r4ceZdZUdZeed<eed<eed<edefdZede fdZ edefdZ ede e fd Zedefd Zy ) DiscussionCommentazA comment in a Discussion / Pull Request. Subclass of [`DiscussionEvent`]. Attributes: 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. contenteditedhiddenrc,|jdddS)z&The rendered comment, as a HTML stringdatalatesthtmlr>rs r renderedzDiscussionComment.rendereds{{6"8,V44r"c>t|jdddS)+The last edit time, as a `datetime` object.rGrH updatedAt)r r>rs r last_edited_atz DiscussionComment.last_edited_ats"dkk&1(;KHIIr"cf|jddjdijddS)rMrGrHrnamedeleted)r>getrs r last_edited_byz DiscussionComment.last_edited_bys2{{6"8,002>BB69UUr"c&|jddS)zThe edit history of the commentrGhistoryrJrs r edit_historyzDiscussionComment.edit_historys{{6"9--r"c,t|jS)N)lenrWrs r number_of_editsz!DiscussionComment.number_of_editss4$$%%r"N)r'r(r)r*r+r,r/r0rKrrOrTrr?rWr.rZr1r"r rBrBs0L L L 5#55JJJVVV.d4j..&&&r"rBceZdZUdZeed<y)DiscussionStatusChangeaVA change of status in a Discussion / Pull Request. Subclass of [`DiscussionEvent`]. Attributes: 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 ) new_statusNr'r(r)r*r+r,r1r"r r\r\s.Or"r\c&eZdZUdZeed<eed<y)DiscussionCommitaA commit in a Pull Request. Subclass of [`DiscussionEvent`]. Attributes: 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. summaryoidNr^r1r"r r`r`s*L Hr"r`c&eZdZUdZeed<eed<y)DiscussionTitleChangeaA rename event in a Discussion / Pull Request. Subclass of [`DiscussionEvent`]. Attributes: 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. old_title new_titleNr^r1r"r rdrd)s*NNr"rdeventrc|d}|d}t|d}||||jdijdd|d}|dk(r&tdi||d d |d d |d d d dS|dk(rtdi|d|d diS|dk(rt di||d d|d ddS|dk(rt di||d d|d ddSt di|S)z.Instantiates a [`DiscussionEvent`] from a dictr<r= createdAtrrQrR)r<r=rrr>commentrGrDrErHraw)rDrErCz status-changer]rcommitsubjectrb)rarbz title-changefromto)rerfr1)r rSrBr\r`rdr4)rgevent_id event_typer common_argss r deserialize_eventrsDsX$KHFmJk 23J ))Hb)--fi@ (KY   =*=*&M(+E2   _$%  V}X.  X  &M),f e$  ^#$  FmF+FmD)   )[ ))r"N)r* dataclassesrrtypingrrrrr r utilsr r-rr3r;r4rBr\r`rdr?rsr1r"r rxs"<<!>? @Z@Z @ZF 7J7 7t) NN N@ 3&3& 3&l _ 6     4 O 4'*T'*o'*r"