nautobot-app-circuit-maintenance icon indicating copy to clipboard operation
nautobot-app-circuit-maintenance copied to clipboard

Pydantic Errors on EmailSource and GmailAPI

Open qduk opened this issue 1 year ago • 4 comments

Environment

  • Python version: 3.8
  • Nautobot version: 1.4.10
  • nautobot-circuit-maintenance version: 1.0.0

Expected Behavior

Tests to run successfully upon initial clone of the repo.

Observed Behavior

It looks like pydantic doesn't like the unannotated field of emails_to_fetch in the EmailSource class and SCOPES of the GmailAPI.

File "/usr/local/lib/python3.8/site-packages/nautobot/extras/plugins/urls.py", line 32, in <module>
    urlpatterns = import_object(f"{plugin_path}.urls.urlpatterns")
  File "/usr/local/lib/python3.8/site-packages/nautobot/extras/plugins/utils.py", line 45, in import_object
    spec.loader.exec_module(module)
  File "/source/nautobot_circuit_maintenance/urls.py", line 5, in <module>
    from . import views
  File "/source/nautobot_circuit_maintenance/views.py", line 14, in <module>
    from nautobot_circuit_maintenance.handle_notifications.sources import RedirectAuthorize, Source
  File "/source/nautobot_circuit_maintenance/handle_notifications/sources.py", line 185, in <module>
    class EmailSource(Source):  # pylint: disable=abstract-method
  File "/usr/local/lib/python3.8/site-packages/pydantic/_internal/_model_construction.py", line 95, in __new__
    private_attributes = inspect_namespace(
  File "/usr/local/lib/python3.8/site-packages/pydantic/_internal/_model_construction.py", line 328, in inspect_namespace
    raise PydanticUserError(
pydantic.errors.PydanticUserError: A non-annotated attribute was detected: `emails_to_fetch = []`. All model fields require a type annotation; if `emails_to_fetch` 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.0.1/u/model-field-missing-annotation
 File "/source/nautobot_circuit_maintenance/views.py", line 14, in <module>
    from nautobot_circuit_maintenance.handle_notifications.sources import RedirectAuthorize, Source
  File "/source/nautobot_circuit_maintenance/handle_notifications/sources.py", line 415, in <module>
    class GmailAPI(EmailSource):
  File "/usr/local/lib/python3.8/site-packages/pydantic/_internal/_model_construction.py", line 95, in __new__
    private_attributes = inspect_namespace(
  File "/usr/local/lib/python3.8/site-packages/pydantic/_internal/_model_construction.py", line 328, in inspect_namespace
    raise PydanticUserError(
pydantic.errors.PydanticUserError: A non-annotated attribute was detected: `SCOPES = ['https://www.googleapis.com/auth/gmail.readonly']`. All model fields require a type annotation; if `SCOPES` 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.0.1/u/model-field-missing-annotation

Steps to Reproduce

  1. Clone repo
  2. Run invoke tests

qduk avatar Jul 05 '23 15:07 qduk