Skip to content

Commit 94eef39

Browse files
committed
Add ruff linting and fixes as a pre-commit hook
Signed-off-by: Rahul Krishna <[email protected]>
1 parent a4f3a53 commit 94eef39

23 files changed

+186
-53
lines changed

.github/workflows/release_config.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,4 +62,4 @@
6262
"ignore_labels": [
6363
"ignore"
6464
]
65-
}
65+
}

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,4 +175,4 @@ cython_debug/
175175

176176
# Project-specific files
177177
.codeanalyzer
178-
.vscode/
178+
.vscode/

.pre-commit-config.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
repos:
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v4.4.0
4+
hooks:
5+
- id: trailing-whitespace
6+
- id: end-of-file-fixer
7+
- id: check-yaml
8+
- id: check-added-large-files
9+
10+
- repo: https://github.com/astral-sh/ruff-pre-commit
11+
rev: v0.1.9
12+
hooks:
13+
- id: ruff
14+
args: [--fix, --exit-non-zero-on-fix]
15+
- id: ruff-format

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1818
### Changed
1919
- Improved CLI error handling with proper logging when input path does not exist
2020
- Test configuration updates:
21-
- Removed unused app import from conftest.py
21+
- Removed unused app import from conftest.py
2222
- Updated test_cli_call_symbol_table to use verbose flag (-v) instead of --quiet flag
2323
- Improved virtual environment creation error handling with informative error messages
2424
- Enhanced `_get_base_interpreter()` method with robust Python interpreter detection across different environments

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,8 @@ To view the available options and commands, run `codeanalyzer --help`. You shoul
118118
```bash
119119
codeanalyzer --input ./my-python-project --codeql
120120
```
121-
This will perform CodeQL-based analysis in addition to the standard symbol table generation.
122-
121+
This will perform CodeQL-based analysis in addition to the standard symbol table generation.
122+
123123
***Note: Not yet fully implemented. Please refrain from using this option until further notice.***
124124

125125
4. **Eager analysis with custom cache directory:**
@@ -170,7 +170,7 @@ uv run codeanalyzer --input /path/to/python/project
170170
### Running Tests
171171

172172
```bash
173-
uv run pytest --pspec -s
173+
uv run pytest --pspec -s
174174
```
175175

176176
### Development Dependencies

RELEASE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,4 +143,4 @@ This release establishes CodeAnalyzer Python as the foundational static analysis
143143

144144
---
145145

146-
*For issues, feature requests, or contributions, visit our [GitHub repository](https://github.com/codellm-devkit/codeanalyzer-python).*
146+
*For issues, feature requests, or contributions, visit our [GitHub repository](https://github.com/codellm-devkit/codeanalyzer-python).*

codeanalyzer/__main__.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
from contextlib import nullcontext
21
import sys
3-
import typer
4-
from typing import Optional, Annotated
2+
from contextlib import nullcontext
53
from pathlib import Path
6-
from codeanalyzer.utils import _set_log_level
7-
from codeanalyzer.utils import logger
4+
from typing import Annotated, Optional
5+
6+
import typer
7+
88
from codeanalyzer.core import AnalyzerCore
9+
from codeanalyzer.utils import _set_log_level, logger
910

1011

1112
def main(

codeanalyzer/core.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,16 @@
11
import hashlib
22
import os
3-
from pdb import set_trace
43
import shutil
54
import subprocess
6-
from pathlib import Path
75
import sys
8-
from typing import Any, Dict, Union, Optional
9-
from codeanalyzer.utils import logger
6+
from pathlib import Path
7+
from typing import Any, Dict, Optional, Union
108

119
from codeanalyzer.schema.py_schema import PyApplication, PyModule
1210
from codeanalyzer.semantic_analysis.codeql import CodeQLLoader
13-
from codeanalyzer.semantic_analysis.codeql.codeql_exceptions import (
14-
CodeQLExceptions,
15-
)
11+
from codeanalyzer.semantic_analysis.codeql.codeql_exceptions import CodeQLExceptions
1612
from codeanalyzer.syntactic_analysis.symbol_table_builder import SymbolTableBuilder
13+
from codeanalyzer.utils import logger
1714

1815

1916
class AnalyzerCore:

codeanalyzer/schema/__init__.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
from .py_schema import (
22
PyApplication,
3-
PyImport,
3+
PyCallable,
4+
PyCallableParameter,
5+
PyClass,
6+
PyClassAttribute,
47
PyComment,
8+
PyImport,
59
PyModule,
6-
PyClass,
710
PyVariableDeclaration,
8-
PyCallable,
9-
PyClassAttribute,
10-
PyCallableParameter
1111
)
1212

1313
__all__ = [
@@ -19,5 +19,5 @@
1919
"PyVariableDeclaration",
2020
"PyCallable",
2121
"PyClassAttribute",
22-
"PyCallableParameter"
22+
"PyCallableParameter",
2323
]

codeanalyzer/schema/py_schema.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@
2020
for static analysis purposes.
2121
"""
2222

23+
import inspect
2324
from pathlib import Path
2425
from typing import Any, Dict, List, Optional
25-
from typing_extensions import Literal
26-
from pydantic import BaseModel
2726

28-
import inspect
27+
from pydantic import BaseModel
28+
from typing_extensions import Literal
2929

3030

3131
def builder(cls):

0 commit comments

Comments
 (0)