Skip to content

Commit

Permalink
Remove redundant types from parameter docstrings (#607)
Browse files Browse the repository at this point in the history
Sphinx understands the function type annotations.
  • Loading branch information
bluetech committed Jul 10, 2023
1 parent 0801d27 commit a8c144a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
2 changes: 2 additions & 0 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@
}

autodoc_member_order = "bysource"
autodoc_typehints = "both"
autodoc_typehints_description_target = "documented"

# Tell sphinx to treat bare backticks like `foo` as :py:obj:`foo`
default_role = 'py:obj'
Expand Down
22 changes: 10 additions & 12 deletions src/trustme/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,8 @@ def write_to_path(self, path: Union[str, "os.PathLike[str]"], append: bool = Fal
"""Writes the data to the file at the given path.
Args:
path (str|os.PathLike[str]): The path to write to.
append (bool): If False (the default), replace any existing file
path: The path to write to.
append: If False (the default), replace any existing file
with the given name. If True, append to any existing file.
"""
Expand Down Expand Up @@ -186,7 +186,7 @@ def tempfile(self, dir: Optional[str] = None) -> Generator[str, None, None]:
requests.get("https://localhost/...", verify=ca_cert_path)
Args:
dir (str or None): Passed to `tempfile.NamedTemporaryFile`.
dir: Passed to `tempfile.NamedTemporaryFile`.
"""
# On Windows, you can't re-open a NamedTemporaryFile that's still
Expand Down Expand Up @@ -229,7 +229,7 @@ class CA:

def __init__(
self,
parent_cert: Optional["CA"] = None,
parent_cert: Optional[CA] = None,
path_length: int = 9,
organization_name: Optional[str] = None,
organization_unit_name: Optional[str] = None,
Expand Down Expand Up @@ -442,13 +442,12 @@ def issue_cert(
# For backwards compatibility
issue_server_cert = issue_cert

def configure_trust(self, ctx: Union[ssl.SSLContext, "OpenSSL.SSL.Context"]) -> None:
def configure_trust(self, ctx: Union[ssl.SSLContext, OpenSSL.SSL.Context]) -> None:
"""Configure the given context object to trust certificates signed by
this CA.
Args:
ctx (ssl.SSLContext or OpenSSL.SSL.Context): The SSL context to be
modified.
ctx: The SSL context to be modified.
"""
if isinstance(ctx, ssl.SSLContext):
Expand All @@ -473,8 +472,8 @@ def from_pem(cls, cert_bytes: bytes, private_key_bytes: bytes) -> "CA":
you're not ready to switch completely to trustme just yet.
Args:
cert_bytes (bytes): The bytes of the certificate in PEM format
private_key_bytes (bytes): The bytes of the private key in PEM format
cert_bytes: The bytes of the certificate in PEM format
private_key_bytes: The bytes of the private key in PEM format
"""
ca = cls()
ca.parent_cert = None
Expand Down Expand Up @@ -510,12 +509,11 @@ def __init__(self, private_key_pem: bytes, server_cert_pem: bytes, chain_to_ca:
self.private_key_and_cert_chain_pem = (
Blob(private_key_pem + server_cert_pem + b''.join(chain_to_ca)))

def configure_cert(self, ctx: Union[ssl.SSLContext, "OpenSSL.SSL.Context"]) -> None:
def configure_cert(self, ctx: Union[ssl.SSLContext, OpenSSL.SSL.Context]) -> None:
"""Configure the given context object to present this certificate.
Args:
ctx (ssl.SSLContext or OpenSSL.SSL.Context): The SSL context to be
modified.
ctx: The SSL context to be modified.
"""
if isinstance(ctx, ssl.SSLContext):
Expand Down

0 comments on commit a8c144a

Please sign in to comment.