Skip to content

Commit

Permalink
Fix and Apply CI Lint Checks (#108)
Browse files Browse the repository at this point in the history
* fix ci checks

* add style and lint dev dependencies

* sort imports

* add flake8 check to ci

* execute style formatting

* update ci checks

* apply formatting

* ignore pep W503

* fix long lines

* add pytest repeat plugin

* apply docformatter to all docstrings

* add dev tool configuration to pyproject

* align sphinx field indentation
  • Loading branch information
mfleader authored Oct 27, 2023
1 parent dc1fc71 commit 6cbc001
Show file tree
Hide file tree
Showing 15 changed files with 1,901 additions and 1,014 deletions.
20 changes: 14 additions & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,20 @@ jobs:
uses: actions/setup-python@65d7f2d534ac1bc67fcd62888c5f4f3d2cb2b236 # v4
with:
python-version: ${{ matrix.python-version }}
- name: Check isort, black, and flake8
run: |
pip install black flake8 isort
isort --profile black .
black .
flake8 .
- name: install python style and linting tools
run: pip install black flake8 autoflake isort docformatter
- name: Check unused code
run: autoflake --remove-all-unused-imports --remove-unused-variables --check .
- name: Check import order (isort)
run: isort --check --profile black --line-length 79 .
- name: Check docstring formatting
run: docformatter --check --recursive --black --wrap-descriptions 79 --wrap-summaries 79 .
- name: Error and style linting
id: flake8
run: flake8 --max-line-length 79 --ignore E203,W503 .
- name: Check error linting
if: steps.flake8.outputs.number > 0
run: exit 1
- name: Install poetry
run: |
python -m pip install poetry==1.4.2
Expand Down
34 changes: 13 additions & 21 deletions example_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@

@dataclass
class FullName:
"""
A full name holds the first and last name of an individual.
"""
"""A full name holds the first and last name of an individual."""

first_name: typing.Annotated[
str,
Expand All @@ -37,9 +35,8 @@ def __str__(self) -> str:

@dataclass
class Nickname:
"""
A nickname is a simplified form of the name that only holds the preferred name of an individual.
"""
"""A nickname is a simplified form of the name that only holds the
preferred name of an individual."""

nick: typing.Annotated[
str,
Expand All @@ -58,9 +55,8 @@ def __str__(self) -> str:

@dataclass
class InputParams:
"""
This is the data structure for the input parameters of the step defined below.
"""
"""This is the data structure for the input parameters of the step defined
below."""

name: typing.Annotated[
typing.Union[
Expand Down Expand Up @@ -96,24 +92,20 @@ class InputParams:

@dataclass
class SuccessOutput:
"""
This is the output data structure for the success case.
"""
"""This is the output data structure for the success case."""

message: str


@dataclass
class ErrorOutput:
"""
This is the output data structure in the error case.
"""
"""This is the output data structure in the error case."""

error: str


# The following is a decorator (starting with @). We add this in front of our function to define the metadata for our
# step.
# The following is a decorator (starting with @). We add this in front of
# our function to define the metadata for our step.
@plugin.step(
id="hello-world",
name="Hello world!",
Expand All @@ -123,13 +115,13 @@ class ErrorOutput:
def hello_world(
params: InputParams,
) -> typing.Tuple[str, typing.Union[SuccessOutput, ErrorOutput]]:
"""
The function is the implementation for the step. It needs the decorator above to make it into a step. The type
hints for the params are required.
"""The function is the implementation for the step. It needs the decorator
above to make it into a step. The type hints for the params are required.
:param params:
:return: the string identifying which output it is, as well the output structure
:return: the string identifying which output it is, as well the output
structure
"""

return "success", SuccessOutput("Hello, {}!".format(params.name))
Expand Down
Loading

0 comments on commit 6cbc001

Please sign in to comment.