Skip to content

Commit

Permalink
feat(build): update python version to 3.11
Browse files Browse the repository at this point in the history
- Update python version to 3.11 in the CI workflow
- Update the description of the library in the Cargo.toml file
- Add a summary message when evaluating a directory
- Enhance the summary message when evaluating a file

BREAKING CHANGE: The minimum required python version is now 3.11
  • Loading branch information
rohaquinlop committed Feb 10, 2024
1 parent e213ce8 commit f9699f8
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 7 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: '3.10'
python-version: '3.11'
- name: Build wheels
uses: PyO3/maturin-action@v1
with:
Expand All @@ -51,7 +51,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: '3.10'
python-version: '3.11'
architecture: ${{ matrix.target }}
- name: Build wheels
uses: PyO3/maturin-action@v1
Expand All @@ -74,7 +74,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: '3.10'
python-version: '3.11'
- name: Build wheels
uses: PyO3/maturin-action@v1
with:
Expand Down
3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
name = "complexipy"
version = "0.1.0"
edition = "2021"
rust-version = "1.67.1"
authors = ["Robin Quintero <rohaquinlop301@gmail.com>"]
license = "MIT"
description = "Calculate the cognitive complexity of your python files"
description = "An extremely fast Python library to calculate the cognitive complexity of python files, written in Rust."
readme = "README.md"
homepage = "https://github.com/rohaquinlop/complexipy"
repository = "https://github.com/rohaquinlop/complexipy"
Expand Down
4 changes: 2 additions & 2 deletions complexipy/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@ def main(
max_complexity: int = typer.Option(15, "--max-complexity", "-c", help="The maximum complexity allowed, set this value as 0 to set it as unlimited."),
is_dir: bool = typer.Option(False, "--is-dir", "-d", help="Flag that indicates if the path is a directory. If this flag is set, the path will be evaluated as a directory. Otherwise, it will be evaluated as a file."),
):
print("==== Complexipy Summary ====")
print("===== Complexipy =====")

if is_dir:
files = rust.evaluate_dir(path, max_complexity)

print(f"Directory: {path}")
print(f"Max complexity: {max_complexity}")
print(f"Total files: {len(files)}")
for file in files:
print(f"File: {file.file_name} - Cognitive Complexity: {file.complexity}")
else:
print("===== Summary =====")
file = rust.file_cognitive_complexity(path, max_complexity)

print(f"Max complexity: {max_complexity}")
Expand Down
4 changes: 3 additions & 1 deletion src/cognitive_complexity/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,10 @@ pub fn evaluate_dir(path: &str, max_complexity: usize) -> PyResult<Vec<FileCompl
.collect();

let elapsed_time = start_time.elapsed();

println!("===== Summary =====");
println!(
"{}: Analysis time: {:} ms.",
"Directory: {}, Analysis time: {:} ms.",
path.to_string(),
elapsed_time.as_millis()
);
Expand Down

0 comments on commit f9699f8

Please sign in to comment.