8000 Added black code formatter by mjcaley · Pull Request #230 · mjcaley/aiospamc · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Added black code formatter #230

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

Merged
merged 3 commits into from
Aug 22, 2020
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .azure-pipelines/templates/ci_steps.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ steps:
displayName: 'Run mypy static type checking'
continueOnError: true

- script: |
black --check aiospamc
displayName: 'Run black'
continueOnError: true

- script: |
sudo apt-get -y install spamassassin
displayName: 'Install SpamAssassin'
Expand Down
158 changes: 80 additions & 78 deletions aiospamc/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#!/usr/bin/env python3

'''aiospamc package.
"""aiospamc package.

An asyncio-based library to communicate with SpamAssassin's SPAMD service.'''
An asyncio-based library to communicate with SpamAssassin's SPAMD service."""

from typing import SupportsBytes, Union

Expand All @@ -12,26 +12,24 @@
from .responses import Response


__all__ = ('Client',
'MessageClassOption',
'ActionOption',
'Timeout')
__all__ = ("Client", "MessageClassOption", "ActionOption", "Timeout")

__author__ = 'Michael Caley'
__copyright__ = 'Copyright 2016-2020 Michael Caley'
__license__ = 'MIT'
__version__ = '0.6.1'
__email__ = 'mjcaley@darkarctic.com'
__author__ = "Michael Caley"
__copyright__ = "Copyright 2016-2020 Michael Caley"
__license__ = "MIT"
__version__ = "0.6.1"
__email__ = "mjcaley@darkarctic.com"


async def check(
message: Union[bytes, SupportsBytes],
*,
host: str = 'localhost',
port: int = 783,
timeout: Timeout = None,
**kwargs) -> Response:
'''Checks a message if it's spam and return a response with a score header.
message: Union[bytes, SupportsBytes],
*,
host: str = "localhost",
port: int = 783,
timeout: Timeout = None,
**kwargs,
) -> Response:
"""Checks a message if it's spam and return a response with a score header.

:param message: Copy of the message.
:param host: Hostname or IP address of the SPAMD service, defaults to localhost.
Expand Down Expand Up @@ -62,7 +60,7 @@ async def check(
:raises NoPermissionException: Permission denied.
:raises ConfigException: Error in configuration.
:raises TimeoutException: Timeout during connection.
'''
"""

c = Client(host=host, port=port, timeout=timeout, **kwargs)
response = await c.check(message)
Expand All @@ -71,13 +69,14 @@ async def check(


async def headers(
message: Union[bytes, SupportsBytes],
*,
host: str = 'localhost',
port: int = 783,
timeout: Timeout = None,
**kwargs) -> Response:
'''Checks a message if it's spam and return the modified message headers.
message: Union[bytes, SupportsBytes],
*,
host: str = "localhost",
port: int = 783,
timeout: Timeout = None,
**kwargs,
) -> Response:
"""Checks a message if it's spam and return the modified message headers.

:param message: Copy of the message.
:param host: Hostname or IP address of the SPAMD service, defaults to localhost.
Expand Down Expand Up @@ -110,7 +109,7 @@ async def headers(
:raises NoPermissionException: Permission denied.
:raises ConfigException: Error in configuration.
:raises TimeoutException: Timeout during connection.
'''
"""

c = Client(host=host, port=port, timeout=timeout, **kwargs)
response = await c.headers(message)
Expand All @@ -119,12 +118,9 @@ async def headers(


async def ping(
*,
host: str = 'localhost',
port: int = 783,
timeout: Timeout = None,
**kwargs) -> Response:
'''Sends a ping to the SPAMD service.
*, host: str = "localhost", port: int = 783, timeout: Timeout = None, **kwargs
) -> Response:
"""Sends a ping to the SPAMD service.

:param host: Hostname or IP address of the SPAMD service, defaults to localhost.
:param port: Port number for the SPAMD service, defaults to 783.
Expand Down Expand Up @@ -152,7 +148,7 @@ async def ping(
:raises NoPermissionException: Permission denied.
:raises ConfigException: Error in configuration.
:raises TimeoutException: Timeout during connection.
'''
"""

c = Client(host=host, port=port, timeout=timeout, **kwargs)
response = await c.ping()
Expand All @@ -161,13 +157,14 @@ async def ping(


async def process(
message: Union[bytes, SupportsBytes],
*,
host: str = 'localhost',
port: int = 783,
timeout: Timeout = None,
**kwargs) -> Response:
'''Checks a message if it's spam and return a response with a score header.
message: Union[bytes, SupportsBytes],
*,
host: str = "localhost",
port: int = 783,
timeout: Timeout = None,
**kwargs,
) -> R ED4F esponse:
"""Checks a message if it's spam and return a response with a score header.

:param message: Copy of the message.
:param host: Hostname or IP address of the SPAMD service, defaults to localhost.
Expand Down Expand Up @@ -199,7 +196,7 @@ async def process(
:raises NoPermissionException: Permission denied.
:raises ConfigException: Error in configuration.
:raises TimeoutException: Timeout during connection.
'''
"""

c = Client(host=host, port=port, timeout=timeout, **kwargs)
response = await c.process(message)
Expand All @@ -208,13 +205,14 @@ async def process(


async def report(
message: Union[bytes, SupportsBytes],
*,
host: str = 'localhost',
port: int = 783,
timeout: Timeout = None,
**kwargs) -> Response:
'''Checks a message if it's spam and return a response with a score header.
message: Union[bytes, SupportsBytes],
*,
host: str = "localhost",
port: int = 783,
timeout: Timeout = None,
**kwargs,
) -> Response:
"""Checks a message if it's spam and return a response with a score header.

:param message: Copy of the message.
:param host: Hostname or IP address of the SPAMD service, defaults to localhost.
Expand Down Expand Up @@ -245,7 +243,7 @@ async def report(
:raises NoPermissionException: Permission denied.
:raises ConfigException: Error in configuration.
:raises TimeoutException: Timeout during connection.
'''
"""

c = Client(host=host, port=port, timeout=timeout, **kwargs)
response = await c.report(message)
Expand All @@ -254,13 +252,14 @@ async def report(


async def report_if_spam(
message: Union[bytes, SupportsBytes],
*,
host: str = 'localhost',
port: int = 783,
timeout: Timeout = None,
**kwargs) -> Response:
'''Checks a message if it's spam and return a response with a score header.
message: Union[bytes, SupportsBytes],
*,
host: str = "localhost",
port: int = 783,
timeout: Timeout = None,
**kwargs,
) -> Response:
"""Checks a message if it's spam and return a response with a score header.

:param message: Copy of the message.
:param host: Hostname or IP address of the SPAMD service, defaults to localhost.
Expand Down Expand Up @@ -292,21 +291,23 @@ async def report_if_spam(
:raises NoPermissionException: Permission denied.
:raises ConfigException: Error in configuration.
:raises TimeoutException: Timeout during connection.
'''
"""

c = Client(host=host, port=port, timeout=timeout, **kwargs)
response = await c.report_if_spam(message)

return response


1E79
async def symbols(message: Union[bytes, SupportsBytes],
*,
host: str = 'localhost',
port: int = 783,
timeout: Timeout = None,
**kwargs) -> Response:
'''Checks a message if it's spam and return a response with a score header.
async def symbols(
message: Union[bytes, SupportsBytes],
*,
host: str = "localhost",
port: int = 783,
timeout: Timeout = None,
**kwargs,
) -> Response:
"""Checks a message if it's spam and return a response with a score header.

:param message: Copy of the message.
:param host: Hostname or IP address of the SPAMD service, defaults to localhost.
Expand Down Expand Up @@ -338,7 +339,7 @@ async def symbols(message: Union[bytes, SupportsBytes],
:raises NoPermissionException: Permission denied.
:raises ConfigException: Error in configuration.
:raises TimeoutException: Timeout during connection.
'''
"""

c = Client(host=host, port=port, timeout=timeout, **kwargs)
response = await c.symbols(message)
Expand All @@ -347,16 +348,17 @@ async def symbols(message: Union[bytes, SupportsBytes],


async def tell(
message: Union[bytes, SupportsBytes],
message_class: Union[str, MessageClassOption],
*,
host: str = 'localhost',
port: int = 783,
remove_action: Union[str, ActionOption] = None,
set_action: Union[str, ActionOption] = None,
timeout: Timeout = None,
**kwargs) -> Response:
'''Checks a message if it's spam and return a response with a score header.
message: Union[bytes, SupportsBytes],
message_class: Union[str, MessageClassOption],
*,
host: str = "localhost",
port: int = 783,
remove_action: Union[str, ActionOption] = None,
set_action: Union[str, ActionOption] = None,
timeout: Timeout = None,
**kwargs,
) -> Response:
"""Checks a message if it's spam and return a response with a score header.

:param message: Copy of the message.
:param message_class: How to classify the message, either "ham" or "spam".
Expand Down Expand Up @@ -391,14 +393,14 @@ async def tell(
:raises NoPermissionException: Permission denied.
:raises ConfigException: Error in configuration.
:raises TimeoutException: Timeout during connection.
'''
"""

c = Client(host=host, port=port, timeout=timeout, **kwargs)
response = await c.tell(
message=message,
message_class=message_class,
remove_action=remove_action,
set_action=set_action
set_action=set_action,
)

return response
Loading
0