-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathruff.toml
More file actions
196 lines (173 loc) · 6.07 KB
/
ruff.toml
File metadata and controls
196 lines (173 loc) · 6.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
# Ruff configuration for qiskit-mcp-servers monorepo
# https://docs.astral.sh/ruff/configuration/
# Exclude common directories
exclude = [
".bzr",
".direnv",
".eggs",
".git",
".git-rewrite",
".hg",
".ipynb_checkpoints",
".mypy_cache",
".nox",
".pants.d",
".pyenv",
".pytest_cache",
".pytype",
".ruff_cache",
".svn",
".tox",
".venv",
".vscode",
"__pypackages__",
"_build",
"buck-out",
"build",
"dist",
"node_modules",
"site-packages",
"venv",
]
# Line length
line-length = 100
indent-width = 4
# Target Python 3.10+
target-version = "py310"
[lint]
# Enable additional rule sets for comprehensive linting
select = [
"E", # pycodestyle errors
"W", # pycodestyle warnings
"F", # pyflakes
"I", # isort (import sorting)
"N", # pep8-naming
"UP", # pyupgrade
"RUF", # Ruff-specific rules
"B", # flake8-bugbear
"C4", # flake8-comprehensions
"SIM", # flake8-simplify
"TCH", # flake8-type-checking
"PTH", # flake8-use-pathlib
"ERA", # eradicate (commented-out code)
"PL", # pylint
"PERF", # perflint (performance)
]
# Ignore specific rules that may be too strict
ignore = [
"E501", # Line too long (handled by formatter)
"PLR0913", # Too many arguments
"PLR2004", # Magic value used in comparison
"SIM108", # Use ternary operator (sometimes less readable)
]
# Allow fix for all enabled rules (when `--fix` is provided)
fixable = ["ALL"]
unfixable = []
# Allow unused variables when underscore-prefixed
dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"
[lint.per-file-ignores]
# Ignore certain rules in test files (both servers)
"**/tests/**/*.py" = [
"PLR2004", # Magic values are common in tests
"S101", # Use of assert
"S105", # Possible hardcoded password
"S106", # Possible hardcoded password
"PLC0415", # Import outside top-level (common in test fixtures)
"PTH123", # open() vs Path.open() (less critical in tests)
"SIM117", # Nested with statements (sometimes clearer in tests)
]
# Ignore import rules in __init__.py files
"**/__init__.py" = [
"F401", # Unused imports (re-exports)
"F403", # Star imports
]
# Ignore global variable and performance warnings in ibm_runtime.py (intentional design)
"**/ibm_runtime.py" = [
"PLW0602", # Global variable usage without assignment
"PLW0603", # Global variable updates
"PERF203", # Try-except in loop (necessary for error handling)
]
# Ignore specific patterns in utils.py (both servers)
"**/utils.py" = [
"PLW0603", # Global variable updates (HTTP client singleton pattern)
"PTH123", # open() vs Path.open() (reading JSON credentials)
"PLC0415", # Import inside function (asyncio for retry logic)
"PERF203", # Try-except in loop (retry mechanism)
]
# Ignore specific patterns in server.py
"**/server.py" = [
"PLC0415", # Import inside cleanup function (asyncio)
]
# qiskit-gym-mcp-server specific ignores (intentional lazy loading)
"**/qiskit_gym_mcp_server/gym_core.py" = [
"PLC0415", # Import inside function (lazy loading qiskit-gym)
"PLR0912", # Too many branches (gateset parsing)
"C401", # Set comprehension (readability preference)
]
"**/qiskit_gym_mcp_server/training.py" = [
"PLC0415", # Import inside function (lazy loading qiskit-gym)
"PLR0911", # Too many return statements (async training logic)
]
"**/qiskit_gym_mcp_server/synthesis.py" = [
"PLC0415", # Import inside function (lazy loading)
"PLR0911", # Too many return statements (validation)
"RUF046", # Int cast on det (numpy type handling)
]
"**/qiskit_gym_mcp_server/models.py" = [
"PLC0415", # Import inside function (lazy loading qiskit-gym)
"PTH107", # os.remove (backward compatibility)
"PTH123", # open() (config file reading)
]
"**/qiskit_gym_mcp_server/coupling_maps.py" = [
"PLC0415", # Import inside function (math, random)
"PLR0912", # Too many branches (subgraph algorithm)
"PLR0915", # Too many statements (subgraph algorithm)
"C401", # Generator vs comprehension (readability)
"SIM102", # Nested if statements (topology detection logic)
"PERF401", # List comprehension (readability in loop)
]
# Ignore certain rules in examples (intended patterns for demonstration code)
"**/examples/**/*.py" = [
"PLC0415", # Import inside function (lazy loading for optional providers)
"PLR0911", # Too many return statements
"PLR0912", # Too many branches
"PLR0915", # Too many statements
"PERF203", # Try-except in loop (error handling per server)
"RUF059", # Unused unpacked variable (mcp_client for cleanup)
"SIM118", # dict.keys() iteration (more explicit)
"B007", # Unused loop variable (intentional in examples)
"TCH002", # Type-checking import (BaseChatModel for type hint)
]
# Same ignores for Jupyter notebooks in examples
"**/examples/**/*.ipynb" = [
"PLC0415", # Import inside function
"PERF203", # Try-except in loop
"RUF059", # Unused unpacked variable
"B007", # Unused loop variable
"I001", # Import sorting (cell-by-cell execution doesn't need strict sorting)
"W293", # Blank lines with whitespace (notebook formatting)
"ERA001", # Commented out code (examples for users to uncomment)
]
[lint.isort]
known-first-party = ["qiskit_code_assistant_mcp_server", "qiskit_ibm_runtime_mcp_server", "qiskit_gym_mcp_server"]
force-single-line = false
lines-after-imports = 2
section-order = ["future", "standard-library", "third-party", "first-party", "local-folder"]
[lint.mccabe]
# Maximum cyclomatic complexity
max-complexity = 10
[lint.pydocstyle]
# Use Google-style docstrings
convention = "google"
[format]
# Use double quotes for strings
quote-style = "double"
# Indent with spaces
indent-style = "space"
# Respect magic trailing comma
skip-magic-trailing-comma = false
# Auto-detect line ending
line-ending = "auto"
# Enable auto-formatting of code examples in docstrings
docstring-code-format = true
docstring-code-line-length = 80