Skip to content

Commit 85f321f

Browse files
More linting fixes and updating schemas for Pydantic 2.0 (#394)
1 parent 1ab4f5e commit 85f321f

17 files changed

+231
-118
lines changed

.mega-linter.yml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,21 @@ DISABLE:
77
- TEKTON
88
DISABLE_LINTERS:
99
- JSON_PRETTIER
10-
- REPOSITORY_GITLEAKS
11-
- SPELL_CSPELL
12-
- SPELL_PROSELINT
1310
- PYTHON_BANDIT
1411
- PYTHON_FLAKE8
1512
# We use MyPy
1613
- PYTHON_PYLINT
1714
- PYTHON_PYRIGHT
15+
- REPOSITORY_GITLEAKS
16+
- SPELL_CSPELL
17+
- SPELL_LYCHEE
18+
- SPELL_PROSELINT
1819
DISABLE_ERRORS_LINTERS:
1920
- REPOSITORY_DEVSKIM
2021
- REPOSITORY_SEMGREP
2122
DOCKERFILE_HADOLINT_ARGUMENTS: "--ignore DL3008 --ignore DL3018 --ignore DL3013 --ignore DL3059 --ignore DL3005"
23+
COPYPASTE_JSCPD_ARGUMENTS:
24+
- "--ignore '**/handlers/**,**/vector*'"
2225
MARKDOWN_MARKDOWN_LINK_CHECK_CONFIG_FILE: ".markdown-link-check-config.json"
2326
MARKDOWN_MARKDOWN_LINK_CHECK_DISABLE_ERRORS: true
2427
PRINT_ALL_FILES: false
@@ -35,9 +38,10 @@ PYTHON_MYPY_ARGUMENTS:
3538
"--disallow-any-generics",
3639
]
3740
PYTHON_MYPY_CONFIG_FILE: "pyproject.toml"
41+
PYTHON_RUFF_CONFIG_FILE: "pyproject.toml"
3842
REPOSITORY_DEVSKIM_ARGUMENTS: ["-g", ".mypy_cache/*"]
3943
SHOW_ELAPSED_TIME: true
4044
SPELL_MISSPELL_FILTER_REGEX_EXCLUDE: '(\.automation/generated|docs/descriptors)'
41-
YAML_YAMLLINT_FILTER_REGEX_EXCLUDE: '(templates/\.mega-linter\.yml/tests)'
45+
YAML_YAMLLINT_FILTER_REGEX_EXCLUDE: '(templates/\.mega-linter\.yml/tests/**\/tests\/**)'
4246
YAML_PRETTIER_FILTER_REGEX_EXCLUDE: '(templates/\.mega-linter\.yml|mkdocs\.yml)'
4347
YAML_V8R_FILTER_REGEX_EXCLUDE: '(descriptors|templates/\.mega-linter\.yml|\.codecov\.yml)'

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,4 @@ repos:
3838
- --install-types
3939
- --non-interactive
4040
- --strict-optional
41-
- --disallow-any-generics
41+
- --disallow-any-generics

README.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
[![Twitter Follow](https://img.shields.io/twitter/follow/operation_code.svg?style=social&label=Follow&style=social)](https://twitter.com/operation_code)
33
[![Code-style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/ambv/black)
44

5-
6-
[![CircleCI](https://circleci.com/gh/OperationCode/operationcode-pybot.svg?style=svg)](https://circleci.com/gh/OperationCode/operationcode-pybot)
75
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](http://contributor-covenant.org/)
86

97
# OperationCode-Pybot

docker/docker-compose.local.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ services:
55
image: pybot:latest
66
container_name: pybot01
77
ports:
8-
- "8010:8010"
8+
- "8010:8010"
99

1010
ngrok:
1111
image: wernight/ngrok:latest
1212
environment:
13-
- NGROK_PORT=pybot:8010
13+
- NGROK_PORT=pybot:8010
1414
ports:
15-
- "4040:4040"
15+
- "4040:4040"

docker/docker-compose.weaviate.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1+
---
12
version: '3.4'
23
services:
34
weaviate:
45
image: semitechnologies/weaviate:1.19.6
56
ports:
6-
- "8055:8080"
7+
- "8055:8080"
78
environment:
89
QUERY_DEFAULTS_LIMIT: 20
910
AUTHENTICATION_ANONYMOUS_ACCESS_ENABLED: 'true'
@@ -15,4 +16,4 @@ services:
1516
t2v-transformers:
1617
image: semitechnologies/transformers-inference:sentence-transformers-all-mpnet-base-v2
1718
environment:
18-
ENABLE_CUDA: 1
19+
ENABLE_CUDA: 1

docker/docker-compose.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
---
12
version: '3.9'
23

34
services:
@@ -9,4 +10,4 @@ services:
910
dockerfile: docker/Dockerfile
1011
command: uvicorn main:api -host 0.0.0.0 --port 5001 --reload --log-level 'debug'
1112
ports:
12-
- "5001:5001"
13+
- "5001:5001"

main.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,19 +176,29 @@ async def healthz() -> Response: # noqa: D103
176176

177177

178178
@app.command("/mentor_request")
179-
async def handle_mentor_request_command( # noqa: D103
179+
async def handle_mentor_request_command(
180180
context: AsyncBoltContext,
181181
body: dict[str, Any],
182182
) -> None:
183+
"""Handle the /mentor_request command.
184+
185+
:param context: The context of the request from the Bolt framework
186+
:param body: The body of the request
187+
"""
183188
logger.info("STAGE: Processing mentorship request...")
184189
await handle_mentor_request(SlackCommandRequestBody(**body), context)
185190

186191

187192
@app.view("mentorship_request_form_submit")
188-
async def handle_mentorship_request_form_view_submit( # noqa: D103
193+
async def handle_mentorship_request_form_view_submit(
189194
body: dict[str, Any],
190195
context: AsyncBoltContext,
191196
) -> None:
197+
"""Handle the submission of the mentorship request form.
198+
199+
:param body: The body of the request
200+
:param context: The context of the request from the Bolt framework
201+
"""
192202
logger.info("STAGE: Processing mentorship form submission...")
193203
await handle_mentorship_request_form_submit(SlackViewRequestBody(**body), context)
194204

modules/handlers/mentorship_handler.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,10 +120,15 @@ async def handle_mentorship_request_form_submit( # noqa: D103
120120
)
121121

122122

123-
async def handle_mentorship_request_claim( # noqa: D103
123+
async def handle_mentorship_request_claim(
124124
parsed_body: SlackActionRequestBody,
125125
context: AsyncBoltContext,
126126
) -> None:
127+
"""Handle a mentorship request claim submission from Slack.
128+
129+
:param parsed_body: The parsed body of the Slack request.
130+
:param context: The context object for the Slack request.
131+
"""
127132
logger.info("STAGE: Handling mentorship request claim...")
128133
await context.ack()
129134
blocks = parsed_body.message.blocks

modules/models/greeting_models.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1-
from pydantic import BaseModel, Field # noqa: D100
1+
"""Models for the greeting module."""
2+
from pydantic import BaseModel, Field
23

34

4-
class UserInfo(BaseModel): # noqa: D101
5-
id: str = Field( # noqa: A003
5+
class UserInfo(BaseModel):
6+
"""User info schema."""
7+
8+
id: str = Field(
69
...,
710
example="U02RK2AL5LZ",
811
description="The Slack ID of the new user",

modules/models/shared_models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class ValidEnum(str, Enum):
1515
class AirtableUser(BaseModel):
1616
"""Model for Airtable user."""
1717

18-
id: str = Field( # noqa: A003
18+
id: str = Field(
1919
...,
2020
example="usrAuExK7DEWFNiI6",
2121
description="Airtable provided unique ID of the user",

0 commit comments

Comments
 (0)