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

Pygount is printing blank lines #91

Closed
susumuasaga opened this issue Apr 18, 2022 · 7 comments · Fixed by #96 or #99
Closed

Pygount is printing blank lines #91

susumuasaga opened this issue Apr 18, 2022 · 7 comments · Fixed by #96 or #99
Assignees
Labels
Milestone

Comments

@susumuasaga
Copy link

Windows 11
Powershell
Version 1.4.0

After I upgraded, Pygount is printing blank lines:

C:\> pygount src









I downgrade to version 1.3.0 and it is working now:

C:\> pygount src 
0       __unknown__     src     src\spark_tests.egg-info\PKG-INFO
28      Text only       src     src\spark_tests.egg-info\SOURCES.txt
0       Text only       src     src\spark_tests.egg-info\dependency_links.txt
1       Text only       src     src\spark_tests.egg-info\top_level.txt
0       __empty__       src     src\spark_tests\__init__.py
16      Python  src     src\spark_tests\datetime.py
72      Python  src     src\spark_tests\delta.py
0       __unknown__     src     src\spark_tests\sql.puml
113     Python  src     src\spark_tests\sql.py
@roskakori roskakori added the bug label Apr 19, 2022
@roskakori
Copy link
Owner

Hm, might be related to the recent switch to rich to show the output as table. 🤔

Sadly I'm unable to investigate this with a setup similar to yours as I don't access to any Windows 11 box.

You could try to upgrade rich to the most current version:

pip install --upgrade rich

As a workaround, keep using version 1.3.0 until someone can look into this.

@fkubicek
Copy link

fkubicek commented May 18, 2022

I'm on Windows 10 and I also get just a bunch of blank lines instead of any output. Downgrading to 1.3.0 fixes it. I don't use Powershell, just plain cmd. It's broken in both Windows Terminal app and the classical cmd.exe window.

@bkelly312
Copy link

Confirmed on Windows 10 Powershell, pygount 1.4.0
Upgrading rich did not help.

@nelson2005
Copy link

Also confirmed windows 10 pygount v1.4.0, no powershel

@roskakori
Copy link
Owner

Rich 12.6 includes a fix for #2513 which might be related to this. In summary, running python using pythonw results in stdout being None and nothing to be rendered.

@roskakori roskakori added this to the v1.5.0 milestone Dec 4, 2022
@roskakori roskakori modified the milestones: v1.5.0, v1.5.1 Dec 30, 2022
@roskakori roskakori self-assigned this Dec 30, 2022
roskakori added a commit that referenced this issue Dec 30, 2022
Actually this is only a workaround that disables progress tracking for sloccount. Consequently, when redirecting the output to a file there is no progress bar either, which is not ideal usability wise.
roskakori added a commit that referenced this issue Dec 31, 2022
roskakori added a commit that referenced this issue Dec 31, 2022
roskakori added a commit that referenced this issue Dec 31, 2022
…count

#91 Fix missing output on Windows with --format=sloccount
@roskakori
Copy link
Owner

roskakori commented Dec 31, 2022

During the holidays I decided to install Python on my Windows 10 box that otherwise is exclusively used for gaming and finally track this down.

Turns out the bug shows as soon as the output for --format=sloccount is wrapped between:

with Progress(transient=True) as progress:
    try:
        ...
    finally:
        progress.stop()

Even without any progress.track().

I also noticed that using --format=sloccount on macOS in the PyCharm terminal results into weird output where tracking information is mixed with SLOC information. This might not be the case on all terminals but I found it discerning enough on this one.

So I decided to disable progress tracking for --format=sloccount for good. When writing to the terminal this should not be an issue because each file is written immediately, so there is always something going on. The only annoying case is when redirecting the output to a file. Then one can only stare at no output and wait until it's finished. So there might be a better solution but I'm not going to look into it any further.

The other writers do not have this issue because they collect all information where processing files in the background, and only once all are processed, write their findings. By then, the progress is already at 100% and not updated anymore.

roskakori added a commit that referenced this issue Jan 2, 2023
roskakori added a commit that referenced this issue Jan 2, 2023
roskakori added a commit that referenced this issue Jan 2, 2023
roskakori added a commit that referenced this issue Jan 2, 2023
@roskakori
Copy link
Owner

This fix is included with pygount 1.5.1, which is now available from PyPI.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Done
5 participants