Skip to content
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

Fix pydantic upgrade issues #404

Merged
merged 9 commits into from
Dec 17, 2023
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
13 changes: 8 additions & 5 deletions .mega-linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,13 @@ DISABLE_ERRORS_LINTERS:
- REPOSITORY_DEVSKIM
- REPOSITORY_SEMGREP
DOCKERFILE_HADOLINT_ARGUMENTS: "--ignore DL3008 --ignore DL3018 --ignore DL3013 --ignore DL3059 --ignore DL3005"
COPYPASTE_JSCPD_ARGUMENTS:
- "--ignore '**/handlers/**,**/vector*'"
COPYPASTE_JSCPD_ARGUMENTS: "--ignore '**/handlers/**,**/vector*'"
COPYPASTE_JSCPD_DISABLE_ERRORS_IF_LESS_THAN: 28
MARKDOWN_MARKDOWN_LINK_CHECK_CONFIG_FILE: ".markdown-link-check-config.json"
MARKDOWN_MARKDOWN_LINK_CHECK_DISABLE_ERRORS: true
REPOSITORY_CHECKOV_DISABLE_ERRORS: true
REPOSITORY_DEVSKIM_ARGUMENTS: ["-g", ".mypy_cache/*"]
REPOSITORY_TRIVY_DISABLE_ERRORS: true
PRINT_ALL_FILES: false
PYTHON_ISORT_CONFIG_FILE: "pyproject.toml"
PYTHON_MYPY_PRE_COMMANDS:
Expand All @@ -38,10 +41,10 @@ PYTHON_MYPY_ARGUMENTS:
"--disallow-any-generics",
]
PYTHON_MYPY_CONFIG_FILE: "pyproject.toml"
PYTHON_MYPY_DISABLE_ERRORS_IF_LESS_THAN: 28
PYTHON_RUFF_CONFIG_FILE: "pyproject.toml"
REPOSITORY_DEVSKIM_ARGUMENTS: ["-g", ".mypy_cache/*"]
SHOW_ELAPSED_TIME: true
SPELL_MISSPELL_FILTER_REGEX_EXCLUDE: '(\.automation/generated|docs/descriptors)'
YAML_YAMLLINT_FILTER_REGEX_EXCLUDE: '(templates/\.mega-linter\.yml/tests/**\/tests\/**)'
YAML_PRETTIER_FILTER_REGEX_EXCLUDE: '(templates/\.mega-linter\.yml|mkdocs\.yml)'
YAML_YAMLLINT_FILTER_REGEX_EXCLUDE: '(templates/|\.mega-linter\.yml|/tests)'
YAML_PRETTIER_FILTER_REGEX_EXCLUDE: '(templates/|\.mega-linter\.yml|mkdocs\.yml)'
YAML_V8R_FILTER_REGEX_EXCLUDE: '(descriptors|templates/\.mega-linter\.yml|\.codecov\.yml)'
10 changes: 5 additions & 5 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,8 @@

# Sentry monitoring
if "SENTRY_DSN" in os.environ:
# pylint: disable=abstract-class-instantiated
sentry_sdk.init(
dsn=os.getenv("SENTRY_DSN"),
request_bodies="medium",
environment=os.getenv("RUN_ENV", "development"),
)

Expand All @@ -128,7 +126,8 @@

# Start up our job scheduler on FastAPI startup and schedule jobs as needed
@api.on_event("startup")
async def startup_event() -> None: # noqa: D103
async def startup_event() -> None:
"""Startup events for the FastAPI application."""
messages = await app.client.chat_scheduledMessages_list()
for message in messages["scheduled_messages"]:
await app.client.chat_deleteScheduledMessage(
Expand All @@ -154,7 +153,7 @@ async def shutdown_event(): # noqa: ANN201, D103
# @api.post("/pybot/api/v1/slack/invite")
# async def invite_new_user(
# email: str = Body(
# ..., example="[email protected]", description="Email address of the user to invite" # noqa: ERA001
# ..., example="[email protected]", description="Email address of the user to invite"
# ) # noqa: ERA001, RUF100
# ) -> None:
# await app.client.admin_users_invite(
Expand All @@ -171,7 +170,8 @@ async def base_endpoint(req: Request) -> Response: # noqa: D103


@api.get("/healthz")
async def healthz() -> Response: # noqa: D103
async def healthz() -> Response:
"""Health check endpoint for Render."""
return Response(status_code=200)


Expand Down
9 changes: 4 additions & 5 deletions modules/airtable/mentorship_tables.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
"""This module contains the Airtable tables for the mentorship program.""" # noqa: D404
"""Airtable tables for the mentorship program."""
import logging
from functools import cached_property
from itertools import chain
from typing import Any

from pydantic.error_wrappers import ValidationError
from pydantic import ValidationError

from modules.airtable.shared_table import BaseAirtableTable
from modules.models.mentorship_models import (
Expand Down Expand Up @@ -48,9 +48,9 @@ def parse_affiliation_row(row: dict[str, Any]) -> MentorshipAffiliation:
airtable_id=row["id"],
created_at=row["createdTime"],
)
except ValidationError as validation_exception:
except ValidationError:
logger.exception("Error parsing affiliation row", extra={"row": row})
raise validation_exception from validation_exception
raise


class MentorshipMentorsTable(BaseAirtableTable):
Expand Down Expand Up @@ -164,7 +164,6 @@ def mentors_by_skillset(self: "MentorshipSkillsetsTable", skillsets_to_search: l
)
except KeyError:
logger.exception("Key error intercepted retrieving mentors by skillset", extra={"row": row})
pass

# Flatten the array and get unique values
return set(chain(*mentors))
Expand Down
2 changes: 1 addition & 1 deletion modules/airtable/scheduled_message_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import logging
from typing import Any

from pydantic.error_wrappers import ValidationError
from pydantic import ValidationError

from modules.airtable.shared_table import BaseAirtableTable
from modules.models.scheduled_message_models import ScheduledMessageInfo
Expand Down
4 changes: 2 additions & 2 deletions modules/models/mentorship_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,5 +181,5 @@ class MentorshipRequest(MentorshipRequestBase, AirtableRowBaseModel): # noqa: D
)


class MentorshipRequestCreate(MentorshipRequestBase): # noqa: D101
pass
class MentorshipRequestCreate(MentorshipRequestBase):
"""Create a new mentorship request."""
Loading