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

update ruff, move ruff settings to ruff.toml #1337

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
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
4 changes: 4 additions & 0 deletions .semversioner/next-release/patch-20241030195954756064.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"type": "patch",
"description": "update project settings"
}
27 changes: 17 additions & 10 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,11 @@
"typescript.preferences.importModuleSpecifierEnding": "js",
"explorer.fileNesting.enabled": true,
"explorer.fileNesting.patterns": {
"*.ts": "${capture}.ts, ${capture}.hooks.ts, ${capture}.hooks.tsx, ${capture}.contexts.ts, ${capture}.stories.tsx, ${capture}.story.tsx, ${capture}.spec.tsx, ${capture}.base.ts, ${capture}.base.tsx, ${capture}.types.ts, ${capture}.styles.ts, ${capture}.styles.tsx, ${capture}.utils.ts, ${capture}.utils.tsx, ${capture}.constants.ts, ${capture}.module.scss, ${capture}.module.css, ${capture}.md",
"*.js": "${capture}.js.map, ${capture}.min.js, ${capture}.d.ts",
"*.jsx": "${capture}.js",
"*.tsx": "${capture}.ts, ${capture}.hooks.ts, ${capture}.hooks.tsx, ${capture}.contexts.ts, ${capture}.stories.tsx, ${capture}.story.tsx, ${capture}.spec.tsx, ${capture}.base.ts, ${capture}.base.tsx, ${capture}.types.ts, ${capture}.styles.ts, ${capture}.styles.tsx, ${capture}.utils.ts, ${capture}.utils.tsx, ${capture}.constants.ts, ${capture}.module.scss, ${capture}.module.css, ${capture}.md, ${capture}.css",
"tsconfig.json": "tsconfig.*.json",
"package.json": "package-lock.json, turbo.json, tsconfig.json, rome.json, biome.json, .npmignore, dictionary.txt, cspell.config.yaml",
"README.md": "*.md, LICENSE, CODEOWNERS",
".eslintrc": ".eslintignore",
".prettierrc": ".prettierignore",
".gitattributes": ".gitignore",
".yarnrc.yml": "yarn.lock, .pnp.*",
"jest.config.js": "jest.setup.mjs",
"pyproject.toml": "poetry.lock, poetry.toml, mkdocs.yaml",
"pyproject.toml": "*.lock, *.toml, mkdocs.yaml",
"cspell.config.yaml": "dictionary.txt"
},
"azureFunctions.postDeployTask": "npm install (functions)",
Expand All @@ -36,6 +28,19 @@
"node_modules{,/**}",
".vscode{,/**}"
],
"[python]": {
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.organizeImports": "explicit",
"source.fixAll": "explicit"
},
"editor.defaultFormatter": "charliermarsh.ruff"
},
"notebook.formatOnSave.enabled": true,
"notebook.codeActionsOnSave": {
"notebook.source.fixAll": "explicit",
"notebook.source.organizeImports": "explicit"
},
"python.defaultInterpreterPath": "python/services/.venv/bin/python",
"python.languageServer": "Pylance",
"cSpell.customDictionaries": {
Expand All @@ -47,5 +52,7 @@
},
"custom": true, // Enable the `custom` dictionary
"internal-terms": true // Disable the `internal-terms` dictionary
}
},
"ruff.configuration": "./ruff.toml",
"ruff.nativeServer": "on"
}
1 change: 1 addition & 0 deletions cspell.config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ ignorePaths:
- temp_azurite/
- __pycache__
- pyproject.toml
- ruff.toml
- entity_extraction.txt
- package.json
- tests/fixtures/
Expand Down
8 changes: 4 additions & 4 deletions graphrag/query/structured_search/global_search/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -332,10 +332,10 @@ async def _reduce_response(
for point in filtered_key_points:
formatted_response_data = []
formatted_response_data.append(
f'----Analyst {point["analyst"] + 1}----'
f"----Analyst {point['analyst'] + 1}----"
)
formatted_response_data.append(
f'Importance Score: {point["score"]}' # type: ignore
f"Importance Score: {point['score']}" # type: ignore
)
formatted_response_data.append(point["answer"]) # type: ignore
formatted_response_text = "\n".join(formatted_response_data)
Expand Down Expand Up @@ -431,8 +431,8 @@ async def _stream_reduce_response(
total_tokens = 0
for point in filtered_key_points:
formatted_response_data = [
f'----Analyst {point["analyst"] + 1}----',
f'Importance Score: {point["score"]}',
f"----Analyst {point['analyst'] + 1}----",
f"Importance Score: {point['score']}",
point["answer"],
]
formatted_response_text = "\n".join(formatted_response_data)
Expand Down
105 changes: 52 additions & 53 deletions poetry.lock

Large diffs are not rendered by default.

96 changes: 2 additions & 94 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,11 @@ ipykernel = "^6.29.4"
jupyter = "^1.1.1"
nbconvert = "^7.16.3"
poethepoet = "^0.28.0"
pyright = "^1.1.384"
pyright = "^1.1.387"
pytest = "^8.3.2"
pytest-asyncio = "^0.24.0"
pytest-timeout = "^2.3.1"
ruff = "^0.6.9"
ruff = "^0.7.1"
semversioner = "^2.0.3"
update-toml = "^0.2.1"
deptry = "^0.20.0"
Expand Down Expand Up @@ -171,98 +171,6 @@ ignore_fail = 'return_non_zero'
sequence = ['_test_all', 'coverage_report']
ignore_fail = 'return_non_zero'

[tool.ruff]
target-version = "py310"
extend-include = ["*.ipynb"]

[tool.ruff.format]
preview = true
docstring-code-format = true
docstring-code-line-length = 20

[tool.ruff.lint]
preview = true
select = [
"E4",
"E7",
"E9",
"W291",
"YTT",
"T10",
"ICN",
"INP",
"Q",
"RSE",
"SLOT",
"INT",
"FLY",
"LOG",
"C90",
"T20",
"D",
"RET",
"PD",
"N",
"PIE",
"SIM",
"S",
"G",
"ERA",
"ASYNC",
"TID",
"UP",
"SLF",
"BLE",
"C4",
"I",
"F",
"A",
"ARG",
"PTH",
"RUF",
"B",
"TCH",
"DTZ",
"PYI",
"PT",
"EM",
"TRY",
"PERF",
"CPY",
# "FBT", # use named arguments for boolean flags
# "TD", # todos
# "FIX", # fixme
# "FURB" # preview rules
# ANN # Type annotations, re-enable when we get bandwidth
]
ignore = [
# Ignore module names shadowing Python builtins
"A005",
# Deprecated Rules
"ANN101",
"ANN102",
# Conflicts with interface argument checking
"ARG002",
"ANN204",
# TODO: Inspect these pandas rules for validity
"PD002", # prevents inplace=True
# TODO RE-Enable when we get bandwidth
"PERF203", # Needs restructuring of errors, we should bail-out on first error
"C901", # needs refactoring to remove cyclomatic complexity
]

[tool.ruff.lint.per-file-ignores]
"tests/*" = ["S", "D", "ANN", "T201", "ASYNC", "ARG", "PTH", "TRY"]
"examples/*" = ["S", "D", "ANN", "T201", "PTH", "TRY", "PERF"]
"graphrag/index/config/*" = ["TCH"]
"*.ipynb" = ["T201"]

[tool.ruff.lint.flake8-builtins]
builtins-ignorelist = ["input", "id", "bytes"]

[tool.ruff.lint.pydocstyle]
convention = "numpy"

# https://github.com/microsoft/pyright/blob/9f81564a4685ff5c55edd3959f9b39030f590b2f/docs/configuration.md#sample-pyprojecttoml-file
[tool.pyright]
include = ["graphrag", "tests", "examples", "examples_notebooks"]
Expand Down
91 changes: 91 additions & 0 deletions ruff.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@

target-version = "py310"
extend-include = ["*.ipynb"]

[format]
preview = true
docstring-code-format = true
docstring-code-line-length = 20

[lint]
preview = true
select = [
"E4",
"E7",
"E9",
"W291",
"YTT",
"T10",
"ICN",
"INP",
"Q",
"RSE",
"SLOT",
"INT",
"FLY",
"LOG",
"C90",
"T20",
"D",
"RET",
"PD",
"N",
"PIE",
"SIM",
"S",
"G",
"ERA",
"ASYNC",
"TID",
"UP",
"SLF",
"BLE",
"C4",
"I",
"F",
"A",
"ARG",
"PTH",
"RUF",
"B",
"TCH",
"DTZ",
"PYI",
"PT",
"EM",
"TRY",
"PERF",
"CPY",
# "FBT", # use named arguments for boolean flags
# "TD", # todos
# "FIX", # fixme
# "FURB" # preview rules
# ANN # Type annotations, re-enable when we get bandwidth
]
ignore = [
# Ignore module names shadowing Python builtins
"A005",
# Deprecated Rules
"ANN101",
"ANN102",
# Conflicts with interface argument checking
"ARG002",
"ANN204",
# TODO: Inspect these pandas rules for validity
"PD002", # prevents inplace=True
# TODO RE-Enable when we get bandwidth
"PERF203", # Needs restructuring of errors, we should bail-out on first error
"C901", # needs refactoring to remove cyclomatic complexity
]

[lint.per-file-ignores]
"tests/*" = ["S", "D", "ANN", "T201", "ASYNC", "ARG", "PTH", "TRY"]
"examples/*" = ["S", "D", "ANN", "T201", "PTH", "TRY", "PERF"]
"graphrag/index/config/*" = ["TCH"]
"*.ipynb" = ["T201"]

[lint.flake8-builtins]
builtins-ignorelist = ["input", "id", "bytes"]

[lint.pydocstyle]
convention = "numpy"
12 changes: 6 additions & 6 deletions tests/integration/_pipeline/test_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@ def _assert_text_units_and_entities_reference_each_other(
entity_ids = set(entity_text_unit_map.keys())

for text_unit_id, text_unit_entities in text_unit_entity_map.items():
assert text_unit_entities.issubset(
entity_ids
), f"Text unit {text_unit_id} has entities {text_unit_entities} that are not in the entity set"
assert text_unit_entities.issubset(entity_ids), (
f"Text unit {text_unit_id} has entities {text_unit_entities} that are not in the entity set"
)
for entity_id, entity_text_units in entity_text_unit_map.items():
assert entity_text_units.issubset(
text_unit_ids
), f"Entity {entity_id} has text units {entity_text_units} that are not in the text unit set"
assert entity_text_units.issubset(text_unit_ids), (
f"Entity {entity_id} has text units {entity_text_units} that are not in the text unit set"
)
Loading
Loading