Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CI: add docformatter to precommit #2614

Merged
merged 19 commits into from
Mar 3, 2024
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 7 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,13 @@ repos:
- id: codespell
additional_dependencies: [tomli]

- repo: https://github.com/PyCQA/docformatter
rev: v1.7.5
hooks:
- id: docformatter
additional_dependencies: [tomli]
args: ["--in-place"]
Borda marked this conversation as resolved.
Show resolved Hide resolved
Borda marked this conversation as resolved.
Show resolved Hide resolved

- repo: https://github.com/psf/black
rev: 23.12.0
hooks:
Expand Down
4 changes: 1 addition & 3 deletions github/AccessToken.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,7 @@


class AccessToken(NonCompletableGithubObject):
"""
This class represents access tokens.
"""
"""This class represents access tokens."""

_created: datetime

Expand Down
12 changes: 6 additions & 6 deletions github/AdvisoryCredit.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,7 @@


class SimpleCredit(TypedDict):
"""
A simple credit for a security advisory.
"""
"""A simple credit for a security advisory."""

login: str | github.NamedUser.NamedUser
type: str
Expand All @@ -47,9 +45,11 @@ class SimpleCredit(TypedDict):


class AdvisoryCredit(NonCompletableGithubObject):
"""
This class represents a credit that is assigned to a SecurityAdvisory.
The reference can be found here https://docs.github.com/en/rest/security-advisories/repository-advisories
"""This class represents a credit that is assigned to a SecurityAdvisory.

The reference can be found here
https://docs.github.com/en/rest/security-advisories/repository-advisories

"""

@property
Expand Down
8 changes: 5 additions & 3 deletions github/AdvisoryCreditDetailed.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,11 @@


class AdvisoryCreditDetailed(NonCompletableGithubObject):
"""
This class represents a credit that is assigned to a SecurityAdvisory.
The reference can be found here https://docs.github.com/en/rest/security-advisories/repository-advisories
"""This class represents a credit that is assigned to a SecurityAdvisory.

The reference can be found here
https://docs.github.com/en/rest/security-advisories/repository-advisories

"""

@property
Expand Down
16 changes: 7 additions & 9 deletions github/AdvisoryVulnerability.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,18 +38,14 @@


class SimpleAdvisoryVulnerabilityPackage(TypedDict):
"""
A simple package in an advisory.
"""
"""A simple package in an advisory."""

ecosystem: str
name: str | None


class SimpleAdvisoryVulnerability(TypedDict):
"""
A simple vulnerability in a security advisory.
"""
"""A simple vulnerability in a security advisory."""

package: SimpleAdvisoryVulnerabilityPackage
patched_versions: str | None
Expand All @@ -61,9 +57,11 @@ class SimpleAdvisoryVulnerability(TypedDict):


class AdvisoryVulnerability(NonCompletableGithubObject):
"""
This class represents a package that is vulnerable to a parent SecurityAdvisory.
The reference can be found here https://docs.github.com/en/rest/security-advisories/repository-advisories
"""This class represents a package that is vulnerable to a parent SecurityAdvisory.

The reference can be found here
https://docs.github.com/en/rest/security-advisories/repository-advisories

"""

@property
Expand Down
8 changes: 5 additions & 3 deletions github/AdvisoryVulnerabilityPackage.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,11 @@


class AdvisoryVulnerabilityPackage(NonCompletableGithubObject):
"""
This class represents an identifier for a package that is vulnerable to a parent SecurityAdvisory.
The reference can be found here https://docs.github.com/en/rest/security-advisories/repository-advisories
"""This class represents an identifier for a package that is vulnerable to a parent SecurityAdvisory.

The reference can be found here
https://docs.github.com/en/rest/security-advisories/repository-advisories

"""

def _initAttributes(self) -> None:
Expand Down
8 changes: 5 additions & 3 deletions github/ApplicationOAuth.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,11 @@


class ApplicationOAuth(NonCompletableGithubObject):
"""
This class is used for identifying and authorizing users for Github Apps.
The reference can be found at https://docs.github.com/en/developers/apps/building-github-apps/identifying-and-authorizing-users-for-github-apps
"""This class is used for identifying and authorizing users for Github Apps.
Borda marked this conversation as resolved.
Show resolved Hide resolved

The reference can be found at
https://docs.github.com/en/developers/apps/building-github-apps/identifying-and-authorizing-users-for-github-apps

"""

def _initAttributes(self) -> None:
Expand Down
4 changes: 1 addition & 3 deletions github/Artifact.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,7 @@


class Artifact(NonCompletableGithubObject):
"""
This class represents an Artifact of Github Run
"""
"""This class represents an Artifact of Github Run."""

def _initAttributes(self) -> None:
self._archive_download_url: Attribute[str] = NotSet
Expand Down
58 changes: 29 additions & 29 deletions github/Auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,24 +47,24 @@

# add new implementations of github.Auth.Auth to docs/utilities.rst
class Auth(abc.ABC):
"""
This class is the base class of all authentication methods for Requester.
"""
"""This class is the base class of all authentication methods for Requester."""

@property
@abc.abstractmethod
def token_type(self) -> str:
"""
The type of the auth token as used in the HTTP Authorization header, e.g. Bearer or Basic.
"""The type of the auth token as used in the HTTP Authorization header, e.g. Bearer or Basic.

:return: token type

"""

@property
@abc.abstractmethod
def token(self) -> str:
"""
The auth token as used in the HTTP Authorization header.
"""The auth token as used in the HTTP Authorization header.

:return: token

"""


Expand All @@ -77,7 +77,7 @@ def username(self) -> str:
@property
@abc.abstractmethod
def password(self) -> str:
"""The password"""
"""The password."""

@property
def token_type(self) -> str:
Expand All @@ -89,9 +89,7 @@ def token(self) -> str:


class Login(HTTPBasicAuth):
"""
This class is used to authenticate with login and password.
"""
"""This class is used to authenticate with login and password."""

def __init__(self, login: str, password: str):
assert isinstance(login, str)
Expand All @@ -116,9 +114,7 @@ def password(self) -> str:


class Token(Auth):
"""
This class is used to authenticate with a single constant token.
"""
"""This class is used to authenticate with a single constant token."""

def __init__(self, token: str):
assert isinstance(token, str)
Expand All @@ -135,9 +131,10 @@ def token(self) -> str:


class JWT(Auth, ABC):
"""
This class is the base class to authenticate with a JSON Web Token (JWT).
"""This class is the base class to authenticate with a JSON Web Token (JWT).

https://docs.github.com/en/apps/creating-github-apps/authenticating-with-a-github-app/generating-a-json-web-token-jwt-for-a-github-app

"""

@property
Expand All @@ -146,9 +143,10 @@ def token_type(self) -> str:


class AppAuth(JWT):
"""
This class is used to authenticate as a GitHub App.
"""This class is used to authenticate as a GitHub App.

https://docs.github.com/en/apps/creating-github-apps/authenticating-with-a-github-app/authenticating-as-a-github-app

"""

def __init__(
Expand Down Expand Up @@ -191,12 +189,13 @@ def get_installation_auth(
token_permissions: Optional[Dict[str, str]] = None,
requester: Optional[Requester] = None,
) -> "AppInstallationAuth":
"""
Creates a github.Auth.AppInstallationAuth instance for an installation.
"""Creates a github.Auth.AppInstallationAuth instance for an installation.

:param installation_id: installation id
:param token_permissions: optional permissions
:param requester: optional requester with app authentication
:return:

"""
return AppInstallationAuth(self, installation_id, token_permissions, requester)

Expand Down Expand Up @@ -225,9 +224,10 @@ def create_jwt(self, expiration: Optional[int] = None) -> str:


class AppAuthToken(JWT):
"""
This class is used to authenticate as a GitHub App with a single constant JWT.
"""This class is used to authenticate as a GitHub App with a single constant JWT.

https://docs.github.com/en/apps/creating-github-apps/authenticating-with-a-github-app/authenticating-as-a-github-app

"""

def __init__(self, token: str):
Expand All @@ -241,9 +241,10 @@ def token(self) -> str:


class AppInstallationAuth(Auth, WithRequester["AppInstallationAuth"]):
"""
This class is used to authenticate as a GitHub App Installation.
"""This class is used to authenticate as a GitHub App Installation.

https://docs.github.com/en/apps/creating-github-apps/authenticating-with-a-github-app/authenticating-as-a-github-app-installation

"""

# used to fetch live access token when calling self.token
Expand Down Expand Up @@ -321,9 +322,10 @@ def _get_installation_authorization(self) -> InstallationAuthorization:


class AppUserAuth(Auth, WithRequester["AppUserAuth"]):
"""
This class is used to authenticate as a GitHub App on behalf of a user.
"""This class is used to authenticate as a GitHub App on behalf of a user.

https://docs.github.com/en/apps/creating-github-apps/authenticating-with-a-github-app/authenticating-with-a-github-app-on-behalf-of-a-user

"""

_client_id: str
Expand Down Expand Up @@ -449,9 +451,7 @@ def refresh_expires_at(self) -> Optional[datetime]:


class NetrcAuth(HTTPBasicAuth, WithRequester["NetrcAuth"]):
"""
This class is used to authenticate via .netrc.
"""
"""This class is used to authenticate via .netrc."""

def __init__(self) -> None:
super().__init__()
Expand Down
7 changes: 5 additions & 2 deletions github/Authorization.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,11 @@


class Authorization(github.GithubObject.CompletableGithubObject):
"""
This class represents Authorizations. The reference can be found here https://docs.github.com/en/enterprise-server@3.0/rest/reference/oauth-authorizations
"""This class represents Authorizations.

The reference can be found here
https://docs.github.com/en/enterprise-server@3.0/rest/reference/oauth-authorizations

"""

def _initAttributes(self) -> None:
Expand Down
4 changes: 1 addition & 3 deletions github/AuthorizationApplication.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,7 @@


class AuthorizationApplication(CompletableGithubObject):
"""
This class represents AuthorizationApplications
"""
"""This class represents AuthorizationApplications."""

def _initAttributes(self) -> None:
self._name: Attribute[str] = NotSet
Expand Down
8 changes: 5 additions & 3 deletions github/Autolink.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,11 @@


class Autolink(NonCompletableGithubObject):
"""
This class represents Repository autolinks.
The reference can be found here https://docs.github.com/en/rest/repos/autolinks?apiVersion=2022-11-28
"""This class represents Repository autolinks.

The reference can be found here
https://docs.github.com/en/rest/repos/autolinks?apiVersion=2022-11-28

"""

def _initAttributes(self) -> None:
Expand Down
7 changes: 5 additions & 2 deletions github/Branch.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,11 @@


class Branch(NonCompletableGithubObject):
"""
This class represents Branches. The reference can be found here https://docs.github.com/en/rest/reference/repos#branches
"""This class represents Branches.

The reference can be found here
https://docs.github.com/en/rest/reference/repos#branches

"""

def __repr__(self) -> str:
Expand Down
7 changes: 5 additions & 2 deletions github/BranchProtection.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,11 @@


class BranchProtection(github.GithubObject.CompletableGithubObject):
"""
This class represents Branch Protection. The reference can be found here https://docs.github.com/en/rest/reference/repos#get-branch-protection
"""This class represents Branch Protection.

The reference can be found here
https://docs.github.com/en/rest/reference/repos#get-branch-protection

"""

def __repr__(self) -> str:
Expand Down
8 changes: 5 additions & 3 deletions github/CVSS.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,11 @@


class CVSS(NonCompletableGithubObject):
"""
This class represents a CVSS.
The reference can be found here <https://docs.github.com/en/rest/security-advisories/global-advisories>
"""This class represents a CVSS.

The reference can be found here
<https://docs.github.com/en/rest/security-advisories/global-advisories>

"""

def _initAttributes(self) -> None:
Expand Down
8 changes: 5 additions & 3 deletions github/CWE.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,11 @@


class CWE(CompletableGithubObject):
"""
This class represents a CWE.
The reference can be found here https://docs.github.com/en/rest/security-advisories/repository-advisories
"""This class represents a CWE.

The reference can be found here
https://docs.github.com/en/rest/security-advisories/repository-advisories

"""

def _initAttributes(self) -> None:
Expand Down