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 all 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
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
5 changes: 4 additions & 1 deletion github/AdvisoryCredit.py
Expand Up @@ -49,7 +49,10 @@ 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

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

"""

@property
Expand Down
5 changes: 4 additions & 1 deletion github/AdvisoryCreditDetailed.py
Expand Up @@ -48,7 +48,10 @@
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

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

"""

@property
Expand Down
5 changes: 4 additions & 1 deletion github/AdvisoryVulnerability.py
Expand Up @@ -63,7 +63,10 @@ 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

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

"""

@property
Expand Down
5 changes: 4 additions & 1 deletion github/AdvisoryVulnerabilityPackage.py
Expand Up @@ -49,7 +49,10 @@
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

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

"""

def _initAttributes(self) -> None:
Expand Down
9 changes: 7 additions & 2 deletions github/ApplicationOAuth.py
Expand Up @@ -44,7 +44,10 @@
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

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 Expand Up @@ -85,7 +88,9 @@ def get_login_url(
state: str | None = None,
login: str | None = None,
) -> str:
"""Return the URL you need to redirect a user to in order to authorize your App."""
"""
Return the URL you need to redirect a user to in order to authorize your App.
"""
parameters = {"client_id": self.client_id}
if redirect_uri is not None:
assert isinstance(redirect_uri, str), redirect_uri
Expand Down
2 changes: 1 addition & 1 deletion github/Artifact.py
Expand Up @@ -54,7 +54,7 @@

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

def _initAttributes(self) -> None:
Expand Down
24 changes: 22 additions & 2 deletions github/Auth.py
Expand Up @@ -56,28 +56,36 @@ class Auth(abc.ABC):
def token_type(self) -> str:
"""
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.

:return: token

"""


class HTTPBasicAuth(Auth, abc.ABC):
@property
@abc.abstractmethod
def username(self) -> str:
"""The username."""
"""
The username.
"""

@property
@abc.abstractmethod
def password(self) -> str:
"""The password"""
"""
The password.
"""

@property
def token_type(self) -> str:
Expand Down Expand Up @@ -137,7 +145,9 @@ def token(self) -> str:
class JWT(Auth, ABC):
"""
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 @@ -148,7 +158,9 @@ def token_type(self) -> str:
class AppAuth(JWT):
"""
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 @@ -193,10 +205,12 @@ def get_installation_auth(
) -> "AppInstallationAuth":
"""
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 @@ -227,7 +241,9 @@ 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.

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 @@ -243,7 +259,9 @@ def token(self) -> str:
class AppInstallationAuth(Auth, WithRequester["AppInstallationAuth"]):
"""
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 @@ -323,7 +341,9 @@ 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.

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
6 changes: 5 additions & 1 deletion github/Authorization.py
Expand Up @@ -50,7 +50,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
2 changes: 1 addition & 1 deletion github/AuthorizationApplication.py
Expand Up @@ -40,7 +40,7 @@

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

def _initAttributes(self) -> None:
Expand Down
5 changes: 4 additions & 1 deletion github/Autolink.py
Expand Up @@ -44,7 +44,10 @@
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

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

"""

def _initAttributes(self) -> None:
Expand Down
6 changes: 5 additions & 1 deletion github/Branch.py
Expand Up @@ -78,7 +78,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
6 changes: 5 additions & 1 deletion github/BranchProtection.py
Expand Up @@ -49,7 +49,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
5 changes: 4 additions & 1 deletion github/CVSS.py
Expand Up @@ -45,7 +45,10 @@
class CVSS(NonCompletableGithubObject):
"""
This class represents a CVSS.
The reference can be found here <https://docs.github.com/en/rest/security-advisories/global-advisories>

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

"""

def _initAttributes(self) -> None:
Expand Down
5 changes: 4 additions & 1 deletion github/CWE.py
Expand Up @@ -45,7 +45,10 @@
class CWE(CompletableGithubObject):
"""
This class represents a CWE.
The reference can be found here https://docs.github.com/en/rest/security-advisories/repository-advisories

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

"""

def _initAttributes(self) -> None:
Expand Down
5 changes: 4 additions & 1 deletion github/CheckRun.py
Expand Up @@ -57,7 +57,10 @@
class CheckRun(CompletableGithubObject):
"""
This class represents check runs.
The reference can be found here https://docs.github.com/en/rest/reference/checks#check-runs

The reference can be found here
https://docs.github.com/en/rest/reference/checks#check-runs

"""

def _initAttributes(self) -> None:
Expand Down
2 changes: 2 additions & 0 deletions github/CheckRunAnnotation.py
Expand Up @@ -32,7 +32,9 @@
class CheckRunAnnotation(NonCompletableGithubObject):
"""
This class represents check run annotations.

The reference can be found here: https://docs.github.com/en/rest/reference/checks#list-check-run-annotations

"""

def _initAttributes(self) -> None:
Expand Down
4 changes: 3 additions & 1 deletion github/CheckRunOutput.py
Expand Up @@ -41,7 +41,9 @@


class CheckRunOutput(NonCompletableGithubObject):
"""This class represents the output of check run."""
"""
This class represents the output of check run.
"""

def _initAttributes(self) -> None:
self._annotations_count: Attribute[int] = NotSet
Expand Down
6 changes: 5 additions & 1 deletion github/CheckSuite.py
Expand Up @@ -49,7 +49,11 @@

class CheckSuite(CompletableGithubObject):
"""
This class represents check suites. The reference can be found here https://docs.github.com/en/rest/reference/checks#check-suites
This class represents check suites.

The reference can be found here
https://docs.github.com/en/rest/reference/checks#check-suites

"""

def _initAttributes(self) -> None:
Expand Down
5 changes: 4 additions & 1 deletion github/Clones.py
Expand Up @@ -44,7 +44,10 @@
class Clones(NonCompletableGithubObject):
"""
This class represents a popular Path for a GitHub repository.
The reference can be found here https://docs.github.com/en/rest/reference/repos#get-repository-clones

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

"""

def _initAttributes(self) -> None:
Expand Down
10 changes: 8 additions & 2 deletions github/CodeScanAlert.py
Expand Up @@ -40,7 +40,10 @@
class CodeScanAlert(NonCompletableGithubObject):
"""
This class represents alerts from code scanning.
The reference can be found here https://docs.github.com/en/rest/reference/code-scanning.

The reference can be found here
https://docs.github.com/en/rest/reference/code-scanning.

"""

def _initAttributes(self) -> None:
Expand Down Expand Up @@ -110,7 +113,10 @@ def state(self) -> str:

def get_instances(self) -> PaginatedList[github.CodeScanAlertInstance.CodeScanAlertInstance]:
"""
:calls: `GET` on the URL for instances as provided by Github
Get instances.

:calls: `GET` on the URL for instances as provided by Github.

"""
return PaginatedList(
github.CodeScanAlertInstance.CodeScanAlertInstance,
Expand Down
5 changes: 4 additions & 1 deletion github/CodeScanAlertInstance.py
Expand Up @@ -37,7 +37,10 @@
class CodeScanAlertInstance(NonCompletableGithubObject):
"""
This class represents code scanning alert instances.
The reference can be found here https://docs.github.com/en/rest/reference/code-scanning.

The reference can be found here
https://docs.github.com/en/rest/reference/code-scanning.

"""

def _initAttributes(self) -> None:
Expand Down
5 changes: 4 additions & 1 deletion github/CodeScanAlertInstanceLocation.py
Expand Up @@ -32,7 +32,10 @@
class CodeScanAlertInstanceLocation(NonCompletableGithubObject):
"""
This class represents code scanning alert instance locations.
The reference can be found here https://docs.github.com/en/rest/reference/code-scanning.

The reference can be found here
https://docs.github.com/en/rest/reference/code-scanning.

"""

def _initAttributes(self) -> None:
Expand Down
5 changes: 4 additions & 1 deletion github/CodeScanRule.py
Expand Up @@ -46,7 +46,10 @@
class CodeScanRule(NonCompletableGithubObject):
"""
This class represents Alerts from code scanning.
The reference can be found here https://docs.github.com/en/rest/reference/code-scanning.

The reference can be found here
https://docs.github.com/en/rest/reference/code-scanning.

"""

def _initAttributes(self) -> None:
Expand Down