Skip to content

Commit a50320f

Browse files
authored
Fix pre commit issues (#8)
* Fix formatting * Fix docstrings * Fix mypy issues
1 parent b9ab1fe commit a50320f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+1183
-509
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,4 +129,4 @@ dmypy.json
129129
.pyre/
130130

131131
# VS Code
132-
.vscode
132+
.vscode

.pre-commit-config.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ repos:
3131
hooks:
3232
- id: pydocstyle
3333
args: [--convention=google]
34+
exclude: "tests"
3435

3536
- repo: https://github.com/pre-commit/mirrors-mypy
3637
rev: v0.812

cli/cdevents/cli/__main__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,11 @@
55

66
import click
77
import yaml
8-
9-
from cdevents.cli.constants import LOGGING_CONFIGURATION_FILE
10-
118
from cdevents.cli.artifact import packaged, published
129
from cdevents.cli.branch import created as branch_created
1310
from cdevents.cli.branch import deleted as branch_deleted
1411
from cdevents.cli.build import finished, queued, started
12+
from cdevents.cli.constants import LOGGING_CONFIGURATION_FILE
1513
from cdevents.cli.env import created as env_created
1614
from cdevents.cli.env import deleted as env_deleted
1715
from cdevents.cli.env import modified as env_modified
@@ -84,10 +82,12 @@ def pipelinerun():
8482
pipelinerun.add_command(pipe_finished)
8583
pipelinerun.add_command(pipe_queued)
8684

85+
8786
@click.group(help=add_disclaimer_text("""Commands Repository related CloudEvent."""))
8887
def repository():
8988
"""Click group for command 'repository'."""
9089

90+
9191
repository.add_command(repo_created)
9292
repository.add_command(repo_modified)
9393
repository.add_command(repo_deleted)

cli/cdevents/cli/artifact.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
"""Module for cli artifact commands."""
22
from __future__ import annotations
3+
34
from typing import List
4-
import click
55

6-
from cdevents.cli.utils import add_disclaimer_text, print_function_args
6+
import click
77
from cdevents.cli.cdevents_command import CDeventsCommand
8-
8+
from cdevents.cli.utils import add_disclaimer_text, print_function_args
99
from cdevents.core.artifact import ArtifactPackagedEvent, ArtifactPublishedEvent
1010

11+
1112
# pylint: disable=unused-argument
1213
def common_artifact_options(function):
1314
"""Decorator for common cli options for artifact."""
@@ -52,6 +53,7 @@ def packaged(
5253
version: str = None,
5354
data: List[str] = None,
5455
):
56+
"""Creates an ArtifactPackaged CDEvent."""
5557
print_function_args()
5658
artifact_event = ArtifactPackagedEvent(id=id, name=name, version=version, data=data)
5759
cdevents_command = CDeventsCommand()
@@ -66,6 +68,7 @@ def published(
6668
version: str = None,
6769
data: List[str] = None,
6870
):
71+
"""Creates an ArtifactPublished CDEvent."""
6972
print_function_args()
7073
artifact_event = ArtifactPublishedEvent(id=id, name=name, version=version, data=data)
7174
cdevents_command = CDeventsCommand()

cli/cdevents/cli/branch.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
"""Module for cli branch commands."""
22
from __future__ import annotations
3+
34
from typing import List
4-
import click
55

6-
from cdevents.cli.utils import add_disclaimer_text, print_function_args
6+
import click
77
from cdevents.cli.cdevents_command import CDeventsCommand
8-
8+
from cdevents.cli.utils import add_disclaimer_text, print_function_args
99
from cdevents.core.branch import BranchCreatedEvent, BranchDeletedEvent
1010

11+
1112
# pylint: disable=unused-argument
1213
def common_branch_options(function):
1314
"""Decorator for common cli options for branch."""
@@ -52,6 +53,7 @@ def created(
5253
repoid: str = None,
5354
data: List[str] = None,
5455
):
56+
"""Creates a BranchCreated CDEvent."""
5557
print_function_args()
5658
branch_event = BranchCreatedEvent(id=id, name=name, repoid=repoid, data=data)
5759
cdevents_command = CDeventsCommand()
@@ -66,6 +68,7 @@ def deleted(
6668
repoid: str = None,
6769
data: List[str] = None,
6870
):
71+
"""Creates a BranchDeleted CDEvent."""
6972
print_function_args()
7073
branch_event = BranchDeletedEvent(id=id, name=name, repoid=repoid, data=data)
7174
cdevents_command = CDeventsCommand()

cli/cdevents/cli/build.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
"""Module for cli build commands."""
22
from __future__ import annotations
3+
34
from typing import List
4-
import click
55

6-
from cdevents.cli.utils import add_disclaimer_text, print_function_args
6+
import click
77
from cdevents.cli.cdevents_command import CDeventsCommand
8+
from cdevents.cli.utils import add_disclaimer_text, print_function_args
9+
from cdevents.core.build import BuildFinishedEvent, BuildQueuedEvent, BuildStartedEvent
810

9-
from cdevents.core.build import BuildStartedEvent, BuildQueuedEvent, BuildFinishedEvent
1011

1112
# pylint: disable=unused-argument
1213
def common_build_options(function):
@@ -53,11 +54,13 @@ def started(
5354
artifact: str = None,
5455
data: List[str] = None,
5556
):
57+
"""Creates a BuildStarted CDEvent."""
5658
print_function_args()
5759
build_event = BuildStartedEvent(id=id, name=name, artifact=artifact, data=data)
5860
cdevents_command = CDeventsCommand()
5961
cdevents_command.run(build_event)
6062

63+
6164
@click.command(help=add_disclaimer_text("Build Finished CloudEvent."))
6265
@common_build_options
6366
def finished(
@@ -66,11 +69,13 @@ def finished(
6669
artifact: str = None,
6770
data: List[str] = None,
6871
):
72+
"""Creates a BuildFinished CDEvent."""
6973
print_function_args()
7074
build_event = BuildQueuedEvent(id=id, name=name, artifact=artifact, data=data)
7175
cdevents_command = CDeventsCommand()
7276
cdevents_command.run(build_event)
7377

78+
7479
@click.command(help=add_disclaimer_text("PipelineRun Queued CloudEvent."))
7580
@common_build_options
7681
def queued(
@@ -79,6 +84,7 @@ def queued(
7984
artifact: str = None,
8085
data: List[str] = None,
8186
):
87+
"""Creates a BuildQueued CDEvent."""
8288
print_function_args()
8389
build_event = BuildFinishedEvent(id=id, name=name, artifact=artifact, data=data)
8490
cdevents_command = CDeventsCommand()

cli/cdevents/cli/cdevents_command.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
import logging
33
from abc import ABC
44

5-
from cloudevents.http import CloudEvent
6-
5+
from cdevents.cli.configuration_handler import (
6+
ConfigurationHandler,
7+
new_default_configuration_handler,
8+
)
79
from cdevents.core.event_sender import EventSender
8-
9-
from cdevents.cli.configuration_handler import ConfigurationHandler
10-
from cdevents.cli.configuration_handler import new_default_configuration_handler
10+
from cloudevents.http import CloudEvent
1111

1212

1313
class CDeventsCommand(ABC):
@@ -25,12 +25,10 @@ def __init__(self, config_handler: ConfigurationHandler = None):
2525
self._config_handler = new_default_configuration_handler()
2626

2727
def run(self, event: CloudEvent):
28-
"""run command.
29-
"""
28+
"""Run command."""
3029
e = EventSender(cde_link=self.config_handler.client.host)
3130
e.send(event)
3231

33-
3432
@property
3533
def config_handler(self) -> ConfigurationHandler:
3634
"""Property for configuration handler."""

cli/cdevents/cli/configuration_handler.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,22 +16,20 @@ def get_default_configuration_file() -> str:
1616
"""Returns the default configuration file path."""
1717
return DEFAULT_CONFIGURATION_FILE
1818

19+
1920
def new_default_configuration_handler() -> ConfigurationHandler:
20-
"""Returnes a configuration handler with the default configuration file"""
21+
"""Returns a configuration handler with the default configuration file."""
2122
config_handler: ConfigurationHandler = ConfigurationHandler.create_new(
2223
get_default_configuration_file()
2324
)
2425

2526
return config_handler
2627

2728

28-
def new_configuration_handler_with_override(
29-
client_host, source_name
30-
) -> ConfigurationHandler:
31-
"""Returnes a configuration handler where args override configuration file."""
29+
def new_configuration_handler_with_override(client_host, source_name) -> ConfigurationHandler:
30+
"""Returns a configuration handler where args override configuration file."""
3231
args_as_config = ConfigurationHandler.create_override_config(
33-
client_host=client_host,
34-
source_name=source_name
32+
client_host=client_host, source_name=source_name
3533
)
3634

3735
config_handler: ConfigurationHandler = ConfigurationHandler.create_new(
@@ -45,7 +43,7 @@ class ConfigurationHandler:
4543
"""Class for providing configuration."""
4644

4745
def __init__(self, configuration: dict):
48-
"""Initializes the configuration.
46+
"""Initializes the configuration.
4947
5048
Args:
5149
configuration (dict): The configuration.
@@ -117,6 +115,7 @@ def create_new(
117115
class _ClientConfig:
118116
host: str
119117

118+
120119
@dataclass
121120
class _SourceConfig:
122121
name: str

cli/cdevents/cli/configuration_reader.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
from typing import Union
88

99
import yaml
10-
1110
from cdevents.cli.utils import DictUtils
1211

1312

cli/cdevents/cli/env.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
11
"""Module for cli environment commands."""
22
from __future__ import annotations
3+
34
from typing import List
4-
import click
55

6-
from cdevents.cli.utils import add_disclaimer_text, print_function_args
6+
import click
77
from cdevents.cli.cdevents_command import CDeventsCommand
8+
from cdevents.cli.utils import add_disclaimer_text, print_function_args
9+
from cdevents.core.env import (
10+
EnvEventCreatedEvent,
11+
EnvEventDeletedEvent,
12+
EnvEventModifiedEvent,
13+
)
814

9-
from cdevents.core.env import EnvEventCreatedEvent, EnvEventModifiedEvent, EnvEventDeletedEvent
1015

1116
# pylint: disable=unused-argument
1217
def common_env_options(function):
@@ -52,11 +57,13 @@ def created(
5257
repo: str = None,
5358
data: List[str] = None,
5459
):
60+
"""Creates an EnvironmentCreated CDEvent."""
5561
print_function_args()
5662
env_event = EnvEventCreatedEvent(id=id, name=name, repo=repo, data=data)
5763
cdevents_command = CDeventsCommand()
5864
cdevents_command.run(env_event)
5965

66+
6067
@click.command(help=add_disclaimer_text("Environment Deleted CloudEvent."))
6168
@common_env_options
6269
def deleted(
@@ -65,11 +72,13 @@ def deleted(
6572
repo: str = None,
6673
data: List[str] = None,
6774
):
75+
"""Creates an EnvironmentDeleted CDEvent."""
6876
print_function_args()
6977
env_event = EnvEventModifiedEvent(id=id, name=name, repo=repo, data=data)
7078
cdevents_command = CDeventsCommand()
7179
cdevents_command.run(env_event)
7280

81+
7382
@click.command(help=add_disclaimer_text("Environment Modified CloudEvent."))
7483
@common_env_options
7584
def modified(
@@ -78,6 +87,7 @@ def modified(
7887
repo: str = None,
7988
data: List[str] = None,
8089
):
90+
"""Creates an EnvironmentModified CDEvent."""
8191
print_function_args()
8292
env_event = EnvEventDeletedEvent(id=id, name=name, repo=repo, data=data)
8393
cdevents_command = CDeventsCommand()

0 commit comments

Comments
 (0)