Backblaze / boardwalk

A linear remote execution workflow engine built on top of Ansible
Other
18 stars 1 forks source link

Relax strict type checking (for now) #57

Closed asullivan-blze closed 1 year ago

asullivan-blze commented 1 year ago

Minimal cycles exist to figure out exactly what Pyright/Pydantic is expecting for strict type-checking. Relax the type checking, for the moment.

Current suspicions are that something changed in terms of strictness of Pyright/Pydantic, such that upon execution of Boardwalk code running the current release 0.8.13 pydantic threw the following error.

  Traceback (most recent call last):
    File "/home/****/.local/bin/boardwalk", line 5, in <module>
      from boardwalk.cli import cli
    File "/home/****/.local/lib/python3.10/site-packages/boardwalk/__init__.py", line 5, in <module>
      from .manifest import (
    File "/home/****/.local/lib/python3.10/site-packages/boardwalk/manifest.py", line 16, in <module>
      from boardwalk.state import LocalState
    File "/home/****/.local/lib/python3.10/site-packages/boardwalk/state.py", line 6, in <module>
      from boardwalk.host import Host
    File "/home/****/.local/lib/python3.10/site-packages/boardwalk/host.py", line 25, in <module>
      class Host(BaseModel, extra=Extra.forbid):
    File "/home/****/.local/lib/python3.10/site-packages/pydantic/_internal/_model_construction.py", line 104, in __new__
      private_attributes = inspect_namespace(
    File "/home/****/.local/lib/python3.10/site-packages/pydantic/_internal/_model_construction.py", line 370, in inspect_namespace
      raise PydanticUserError(
  pydantic.errors.PydanticUserError: A non-annotated attribute was detected: `remote_mutex_path = '/opt/boardwalk.mutex'`. All model fields require a type annotation; if `remote_mutex_path` is not meant to be a field, you may be able to resolve this error by annotating it as a `ClassVar` or updating `model_config['ignored_types']`.

  For further information visit https://errors.pydantic.dev/2.4/u/model-field-missing-annotation

Just annotating the strings in question, below, did not fully resolve all Pyright errors in strict mode, so downgrading to basic mode with liberal application of # type: ignore was needed for the moment to get make test to function as expected.

    remote_mutex_path = "/opt/boardwalk.mutex"
    remote_alert_msg = "ALERT: Boardwalk is running a workflow against this host. Services may be interrupted"
    remote_alert_string_formatted = f"$(tput -T xterm bold)$(tput -T xterm setaf 1)'{remote_alert_msg}'$(tput -T xterm sgr0)"
    remote_alert_motd = f"#!/bin/sh\necho {remote_alert_string_formatted}"
    remote_alert_motd_path = "/etc/update-motd.d/99-boardwalk-alert"
    remote_alert_wall_cmd = f"wall {remote_alert_string_formatted}"