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

Running without quiet mode raises TypeError #57

Closed
chan-vince opened this issue Dec 15, 2024 · 6 comments
Closed

Running without quiet mode raises TypeError #57

chan-vince opened this issue Dec 15, 2024 · 6 comments
Labels
bug Something isn't working

Comments

@chan-vince
Copy link

chan-vince commented Dec 15, 2024

Run complexipy against any file or files, without any options; specifically the -q quiet option:

❯ complexipy ./lambda.py               
───────────────────────────────────────────────────────────────────────────────────────────────────── 🐙 complexipy 1.1.0 ──────────────────────────────────────────────────────────────────────────────────────────────────────
╭───────────────────────────────────────────────────────────────────────────────────────────── Traceback (most recent call last) ──────────────────────────────────────────────────────────────────────────────────────────────╮
│ /Users/vince/.pyenv/versions/3.11.9/lib/python3.11/site-packages/complexipy/main.py:71 in main                                                                                                                               │
│                                                                                                                                                                                                                              │
│    68 │   │   console.print(f"Results saved at {output_csv_path}")                             ╭────────────────────────────────────────────────── locals ──────────────────────────────────────────────────╮                │
│    69 │                                                                                        │            details = <DetailTypes.normal: 'normal'>                                                        │                │
│    70 │   if not quiet:                                                                        │     execution_time = 0.0010290145874023438                                                                 │                │
│ ❱  71 │   │   has_success = output_summary(                                                    │ files_complexities = [<complexipy.FileComplexity object at 0x1008dcb90>]                                   │                │
│    72 │   │   │   console, max_complexity, details, paths, sort                                │    invocation_path = '/Users/vince/projects/services/notification-service/functions/notif'+15 │                │
│    73 │   │   )                                                                                │     max_complexity = 15                                                                                    │                │
│    74 │   if quiet:                                                                            │             output = False                                                                                 │                │
│                                                                                                │    output_csv_path = '/Users/vince/projects/services/notification-service/functions/notif'+30 │                │
│                                                                                                │              paths = ['./lambda.py']                                                                       │                │
│                                                                                                │              quiet = False                                                                                 │                │
│                                                                                                │               sort = <Sort.asc: 'asc'>                                                                     │                │
│                                                                                                │         start_time = 1734262551.007355                                                                     │                │
│                                                                                                ╰────────────────────────────────────────────────────────────────────────────────────────────────────────────╯                │
│                                                                                                                                                                                                                              │
│ /Users/vince/.pyenv/versions/3.11.9/lib/python3.11/site-packages/complexipy/utils.py:25 in output_summary                                                                                                                    │
│                                                                                                                                                                                                                              │
│   22 │   details: DetailTypes,                                                                ╭────────────────────────── locals ──────────────────────────╮                                                                 │
│   23 │   sort: Sort,                                                                          │        console = <console width=224 ColorSystem.TRUECOLOR> │                                                                 │
│   24 ) -> bool:                                                                               │        details = ['./lambda.py']                           │                                                                 │
│ ❱ 25 │   table, has_success, total_complexity = create_table(                                 │          files = 15                                        │                                                                 │
│   26 │   │   files, max_complexity, details, sort                                             │ max_complexity = <DetailTypes.normal: 'normal'>            │                                                                 │
│   27 │   )                                                                                    │           sort = <Sort.asc: 'asc'>                         │                                                                 │
│   28                                                                                          ╰────────────────────────────────────────────────────────────╯                                                                 │
│                                                                                                                                                                                                                              │
│ /Users/vince/.pyenv/versions/3.11.9/lib/python3.11/site-packages/complexipy/utils.py:61 in create_table                                                                                                                      │
│                                                                                                                                                                                                                              │
│   58 │   table.add_column("Function")                                                         ╭────────────────────────── locals ───────────────────────────╮                                                                │
│   59 │   table.add_column("Complexity")                                                       │    all_functions = []                                       │                                                                │
│   60 │                                                                                        │       complexity = <DetailTypes.normal: 'normal'>           │                                                                │
│ ❱ 61 │   for file in files:                                                                   │          details = ['./lambda.py']                          │                                                                │
│   62 │   │   for function in file.functions:                                                  │            files = 15                                       │                                                                │
│   63 │   │   │   total_complexity += function.complexity                                      │      has_success = True                                     │                                                                │
│   64 │   │   │   all_functions.append((file.path, file.file_name, function))                  │             sort = <Sort.asc: 'asc'>                        │                                                                │
│                                                                                               │            table = <rich.table.Table object at 0x1021693d0> │                                                                │
│                                                                                               │ total_complexity = 0                                        │                                                                │
│                                                                                               ╰─────────────────────────────────────────────────────────────╯                                                                │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
TypeError: 'int' object is not iterable

Looks like the output_summary() function isn't being called with the correct arguments:

image
@rohaquinlop
Copy link
Owner

OMG 🤦🏾‍♂️ removed the wrong variable when refactored the code, thank you!!

@rohaquinlop rohaquinlop added the bug Something isn't working label Dec 15, 2024
rohaquinlop added a commit that referenced this issue Dec 15, 2024
- The output_summary function call was missing the files_complexities argument.
- This commit fixes the function call by adding the missing argument.
@rohaquinlop
Copy link
Owner

Pending to add unit tests to cover cases like this

rohaquinlop added a commit that referenced this issue Dec 15, 2024
fix(python): #57 fix output_summary function call
@rohaquinlop
Copy link
Owner

@chan-vince The new version is being deployed, thank you for reporting this error!

@rohaquinlop
Copy link
Owner

@chan-vince version 1.2.0 has been released

@chan-vince
Copy link
Author

No worries, it happens 😀
That was quick, thanks!

Re the unit tests - you can actually catch this kind of issue with just a linter like ruff, much less effort for than doing unit tests if there aren't any yet.

@chan-vince
Copy link
Author

@rohaquinlop I can confirm it works again with v1.2.0. Thanks again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants