Skip to content

Commit 4262b1a

Browse files
Configure Neovim and pre-commit to run flake8 and pylint (#1339)
* Configure Neovim (and pre-commit) to run flake8 and pylint Signed-off-by: Jonathan Springer <[email protected]> * Adjust Makefile to match to GitHub CI/CD (ish). Signed-off-by: Jonathan Springer <[email protected]> * Add black to the pre-commit linters Signed-off-by: Jonathan Springer <[email protected]> * fix: Warnings are revealing improperly built tests. Signed-off-by: Jonathan Springer <[email protected]> * chore: add markdown config to nvim for LazyVim Signed-off-by: Jonathan Springer <[email protected]> * fix: Create a lightweight pre-commit configuration to support Make tests and build check Signed-off-by: Jonathan Springer <[email protected]> * fix: correct uv pre-commit command in Makefile The pre-commit target was using 'uv pre-commit run' which is not a valid uv subcommand. Changed to 'uv run pre-commit run' to properly invoke the pre-commit tool through uv's run command. Signed-off-by: Mihai Criveti <[email protected]> --------- Signed-off-by: Jonathan Springer <[email protected]> Signed-off-by: Mihai Criveti <[email protected]> Co-authored-by: Mihai Criveti <[email protected]>
1 parent 86645bb commit 4262b1a

File tree

5 files changed

+601
-42
lines changed

5 files changed

+601
-42
lines changed

.github/workflows/lint.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ jobs:
7070
vulture mcpgateway --min-confidence 80
7171
7272
- id: pylint
73-
setup: pip install pylint pylint-pydantic
74-
cmd: pylint mcpgateway --errors-only --fail-under=10
73+
setup: true
74+
cmd: uv run pylint mcpgateway --fail-on E --fail-under=10
7575

7676
- id: interrogate
7777
setup: pip install interrogate
@@ -131,6 +131,11 @@ jobs:
131131
with:
132132
python-version: "3.12"
133133
cache: pip
134+
# -----------------------------------------------------------
135+
# Install uv
136+
# -----------------------------------------------------------
137+
- name: ⚡Set up uv
138+
uses: astral-sh/setup-uv@v6
134139

135140
# -----------------------------------------------------------
136141
# 2️⃣ Install Project + Dev Dependencies

.nvim.lua

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,34 @@
1-
21
-- Set colorcolumn to 200 for Python files only
32
vim.api.nvim_create_autocmd("FileType", {
4-
pattern = "python",
5-
callback = function()
6-
vim.opt_local.colorcolumn = "200"
7-
end,
3+
pattern = "python",
4+
callback = function()
5+
vim.opt_local.colorcolumn = "200"
6+
end,
7+
})
8+
9+
-- Set up for line formatting .md files to a 120-character limit
10+
vim.api.nvim_create_autocmd("FileType", {
11+
pattern = "markdown",
12+
callback = function()
13+
vim.opt_local.colorcolumn = "120"
14+
vim.opt_local.textwidth = 120
15+
end,
816
})
917

1018
--
1119
-- Project settings for ALE (Asynchronous Lint Engine)
1220
-- ALE is available at https://github.com/dense-analysis/ale
21+
--
1322
vim.g.ale_linters = {
14-
make = {},
15-
python = { "mypy", "ruff" },
16-
markdown = { "markdownlint" },
23+
make = {},
24+
python = { "mypy", "ruff", "flake8", "pylint" },
25+
markdown = { "markdownlint" },
1726
}
1827
vim.g.ale_python_auto_uv = 1
1928

20-
vim.g.ale_python_mypy_options='--no-pretty'
21-
vim.g.ale_python_ruff_options = '--extend-select I'
22-
vim.g.ale_markdown_markdownlint_executable = 'markdownlint-cli2'
29+
vim.g.ale_python_mypy_options = "--no-pretty"
30+
vim.g.ale_python_ruff_options = "--extend-select I"
31+
vim.g.ale_markdown_markdownlint_executable = "markdownlint-cli2"
2332

2433
vim.g.ale_fixers = {
2534
python = { "ruff", "black" },

.pre-commit-config.yaml

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
# report issues (linters). Modified files will need to be staged again.
1919
# -----------------------------------------------------------------------------
2020

21-
exclude: '(^|/)(\.pre-commit-config\.yaml|normalize_special_characters\.py|test_input_validation\.py|ai_artifacts_normalizer\.py)$|(^|/)mcp-servers/templates/|(^|/)tests/load/|.*\.(jinja|j2)$' # ignore these files, all templates, load tests, and jinja files
21+
exclude: '(^|/)(\.pre-commit-.*\.yaml|normalize_special_characters\.py|test_input_validation\.py|ai_artifacts_normalizer\.py)$|(^|/)mcp-servers/templates/|(^|/)tests/load/|.*\.(jinja|j2)$' # ignore these files, all templates, load tests, and jinja files
2222

2323
repos:
2424
# -----------------------------------------------------------------------------
@@ -190,11 +190,6 @@ repos:
190190
description: Removes UTF-8 byte order marker.
191191
types: [text]
192192

193-
- id: fix-encoding-pragma
194-
name: 🧹 Fix Python Encoding Pragma
195-
description: "Adds # -*- coding: utf-8 -*- to the top of python files."
196-
types: [python]
197-
198193
- id: mixed-line-ending
199194
name: 🧹 Mixed Line Ending
200195
description: Replaces or checks mixed line ending.
@@ -371,12 +366,12 @@ repos:
371366
exclude: ^tests/(.*/)?(pages|helpers|fuzzers|scripts|fixtures|migration|utils|manual|async|load)/.*\.py$
372367
args: [--pytest-test-first] # `test_.*\.py`
373368

374-
# - repo: https://github.com/pycqa/flake8
375-
# rev: 7.2.0
376-
# hooks:
377-
# - id: flake8
378-
# name: 🐍 Flake8 - Python Linter
379-
# description: Tool for style guide enforcement.
369+
- repo: https://github.com/pycqa/flake8
370+
rev: 7.2.0
371+
hooks:
372+
- id: flake8
373+
name: 🐍 Flake8 - Python Linter
374+
description: Tool for style guide enforcement.
380375

381376
# - repo: https://github.com/pycqa/bandit
382377
# rev: 1.8.3
@@ -418,13 +413,13 @@ repos:
418413
# types_or: [ python, pyi ]
419414
# files: ^mcpgateway/
420415

421-
# - repo: https://github.com/psf/black
422-
# rev: 25.1.0
423-
# hooks:
424-
# - id: black
425-
# name: 🐍 Black - Python Code Formatter
426-
# description: The uncompromising Python code formatter.
427-
# language_version: python3
416+
- repo: https://github.com/psf/black
417+
rev: 25.1.0
418+
hooks:
419+
- id: black
420+
name: 🐍 Black - Python Code Formatter
421+
description: The uncompromising Python code formatter.
422+
language_version: python3
428423

429424
# - repo: https://github.com/pycqa/isort
430425
# rev: 6.0.1

0 commit comments

Comments
 (0)