Module ogr.abstract.comment
Classes
class Comment (raw_comment: Any | None = None,
parent: Any | None = None,
body: str | None = None,
id_: int | None = None,
author: str | None = None,
created: datetime.datetime | None = None,
edited: datetime.datetime | None = None)-
Expand source code
class Comment(OgrAbstractClass): def __init__( self, raw_comment: Optional[Any] = None, parent: Optional[Any] = None, body: Optional[str] = None, id_: Optional[int] = None, author: Optional[str] = None, created: Optional[datetime.datetime] = None, edited: Optional[datetime.datetime] = None, ) -> None: if raw_comment: self._from_raw_comment(raw_comment) elif body and author: self._body = body self._id = id_ self._author = author self._created = created self._edited = edited else: raise ValueError("cannot construct comment without body and author") self._parent = parent def __str__(self) -> str: body = f"{self.body[:10]}..." if self.body is not None else "None" return ( f"Comment(" f"comment='{body}', " f"author='{self.author}', " f"created='{self.created}', " f"edited='{self.edited}')" ) def _from_raw_comment(self, raw_comment: Any) -> None: """Constructs Comment object from raw_comment given from API.""" raise NotImplementedError() @property def body(self) -> str: """Body of the comment.""" return self._body @body.setter def body(self, new_body: str) -> None: self._body = new_body @property def id(self) -> int: return self._id @property def author(self) -> str: """Login of the author of the comment.""" return self._author @property def created(self) -> datetime.datetime: """Datetime of creation of the comment.""" return self._created @property def edited(self) -> datetime.datetime: """Datetime of last edit of the comment.""" return self._edited def get_reactions(self) -> Union[list[Reaction], Iterable[Reaction]]: """Returns list of reactions.""" raise NotImplementedError() def add_reaction(self, reaction: str) -> Reaction: """ Reacts to a comment. Colons in between reaction are not needed, e.g. `comment.add_reaction("+1")`. Args: reaction: String representing specific reaction to be added. Returns: Object representing newly added reaction. """ raise NotImplementedError()
Ancestors
Subclasses
Instance variables
-
Expand source code
@property def author(self) -> str: """Login of the author of the comment.""" return self._author
Login of the author of the comment.
prop body : str
-
Expand source code
@property def body(self) -> str: """Body of the comment.""" return self._body
Body of the comment.
prop created : datetime.datetime
-
Expand source code
@property def created(self) -> datetime.datetime: """Datetime of creation of the comment.""" return self._created
Datetime of creation of the comment.
prop edited : datetime.datetime
-
Expand source code
@property def edited(self) -> datetime.datetime: """Datetime of last edit of the comment.""" return self._edited
Datetime of last edit of the comment.
prop id : int
-
Expand source code
@property def id(self) -> int: return self._id
Methods
def add_reaction(self, reaction: str) ‑> Reaction
-
Expand source code
def add_reaction(self, reaction: str) -> Reaction: """ Reacts to a comment. Colons in between reaction are not needed, e.g. `comment.add_reaction("+1")`. Args: reaction: String representing specific reaction to be added. Returns: Object representing newly added reaction. """ raise NotImplementedError()
Reacts to a comment.
Colons in between reaction are not needed, e.g.
comment.add_reaction("+1")
.Args
reaction
- String representing specific reaction to be added.
Returns
Object representing newly added reaction.
def get_reactions(self) ‑> list[Reaction] | Iterable[Reaction]
-
Expand source code
def get_reactions(self) -> Union[list[Reaction], Iterable[Reaction]]: """Returns list of reactions.""" raise NotImplementedError()
Returns list of reactions.
-
class CommitComment (sha: str, raw_comment: Any)
-
Expand source code
class CommitComment(Comment): """ Attributes: sha (str): Hash of the related commit. body (str): Body of the comment. author (str): Login of the author. """ def __init__( self, sha: str, raw_comment: Any, ) -> None: super().__init__(raw_comment=raw_comment) self.sha = sha @property # type: ignore @deprecate_and_set_removal( since="0.41.0", remove_in="0.46.0 (or 1.0.0 if it comes sooner)", message="Use body", ) def comment(self) -> str: return self.body def __str__(self) -> str: return ( f"CommitComment(commit={self.sha}, author={self.author}, body={self.body})" )
Attributes
sha
:str
- Hash of the related commit.
body
:str
- Body of the comment.
author
:str
- Login of the author.
Ancestors
Subclasses
Instance variables
prop comment : str
-
Expand source code
@property # type: ignore @deprecate_and_set_removal( since="0.41.0", remove_in="0.46.0 (or 1.0.0 if it comes sooner)", message="Use body", ) def comment(self) -> str: return self.body
Inherited members
class IssueComment (raw_comment: Any | None = None,
parent: Any | None = None,
body: str | None = None,
id_: int | None = None,
author: str | None = None,
created: datetime.datetime | None = None,
edited: datetime.datetime | None = None)-
Expand source code
class IssueComment(Comment): @property def issue(self) -> "Issue": """Issue of issue comment.""" return self._parent def __str__(self) -> str: return "Issue" + super().__str__()
Ancestors
Subclasses
Instance variables
prop issue : Issue
-
Expand source code
@property def issue(self) -> "Issue": """Issue of issue comment.""" return self._parent
Issue of issue comment.
Inherited members
class PRComment (raw_comment: Any | None = None,
parent: Any | None = None,
body: str | None = None,
id_: int | None = None,
author: str | None = None,
created: datetime.datetime | None = None,
edited: datetime.datetime | None = None)-
Expand source code
class PRComment(Comment): @property def pull_request(self) -> "PullRequest": """Pull request of pull request comment.""" return self._parent def __str__(self) -> str: return "PR" + super().__str__()
Ancestors
Subclasses
Instance variables
prop pull_request : PullRequest
-
Expand source code
@property def pull_request(self) -> "PullRequest": """Pull request of pull request comment.""" return self._parent
Pull request of pull request comment.
Inherited members
class Reaction (raw_reaction: Any)
-
Expand source code
class Reaction(OgrAbstractClass): def __init__(self, raw_reaction: Any) -> None: self._raw_reaction = raw_reaction def __str__(self): return f"Reaction(raw_reaction={self._raw_reaction})" def delete(self) -> None: """Delete a reaction.""" raise NotImplementedError()
Ancestors
Subclasses
Methods
def delete(self) ‑> None
-
Expand source code
def delete(self) -> None: """Delete a reaction.""" raise NotImplementedError()
Delete a reaction.