InputGitAuthor.py
1 ############################ Copyrights and license ############################ 2 # # 3 # Copyright 2012 Vincent Jacques <vincent@vincent-jacques.net> # 4 # Copyright 2012 Zearin <zearin@gonk.net> # 5 # Copyright 2013 Vincent Jacques <vincent@vincent-jacques.net> # 6 # Copyright 2014 Nic Dahlquist <nic@snapchat.com> # 7 # Copyright 2014 Vincent Jacques <vincent@vincent-jacques.net> # 8 # Copyright 2016 Jannis Gebauer <ja.geb@me.com> # 9 # Copyright 2016 Peter Buckley <dx-pbuckley@users.noreply.github.com> # 10 # Copyright 2018 Wan Liuyang <tsfdye@gmail.com> # 11 # Copyright 2018 sfdye <tsfdye@gmail.com> # 12 # # 13 # This file is part of PyGithub. # 14 # http://pygithub.readthedocs.io/ # 15 # # 16 # PyGithub is free software: you can redistribute it and/or modify it under # 17 # the terms of the GNU Lesser General Public License as published by the Free # 18 # Software Foundation, either version 3 of the License, or (at your option) # 19 # any later version. # 20 # # 21 # PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY # 22 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # 23 # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more # 24 # details. # 25 # # 26 # You should have received a copy of the GNU Lesser General Public License # 27 # along with PyGithub. If not, see <http://www.gnu.org/licenses/>. # 28 # # 29 ################################################################################ 30 31 from __future__ import annotations 32 33 from typing import Any 34 35 from github.GithubObject import NotSet, Opt, is_defined, is_optional 36 37 38 class InputGitAuthor: 39 """ 40 This class represents InputGitAuthors 41 """ 42 43 def __init__(self, name: str, email: str, date: Opt[str] = NotSet): 44 assert isinstance(name, str), name 45 assert isinstance(email, str), email 46 assert is_optional(date, str), date # @todo Datetime? 47 48 self.__name: str = name 49 self.__email: str = email 50 self.__date: Opt[str] = date 51 52 def __repr__(self) -> str: 53 return f'InputGitAuthor(name="{self.__name}")' 54 55 @property 56 def _identity(self) -> dict[str, str]: 57 identity: dict[str, Any] = { 58 "name": self.__name, 59 "email": self.__email, 60 } 61 if is_defined(self.__date): 62 identity["date"] = self.__date 63 return identity