Skip to content

Added PipEnv ".venv" to directories ignored and log filename when UnicodeDecodeError exception is caught. #185

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

valveca-ai
Copy link

Pipreqs was failing with UnicodeDecodeError without indicating the filename that caused the error. The root case was PipEnv's ".venv" folder was being processed.

This PR adds ".venv" to directories to ignore, and moves the code that reads the file to process inside the try/catch block in order to log the filename that caused the issue.

The file that caused the failure was:

/Users/XXXXX/dev/XXXXX/.venv/lib/python3.7/site-packages/IPython/core/tests/nonascii.py

and the terminal output was:

$ pipreqs --debug 
Traceback (most recent call last):
  File "/Users/XXXXX/dev/XXXXX/.venv/bin/pipreqs", line 10, in <module>
    sys.exit(main())
  File "/Users/XXXXX/dev/XXXXX/.venv/lib/python3.7/site-packages/pipreqs/pipreqs.py", line 470, in main
    init(args)
  File "/Users/XXXXX/dev/XXXXX/.venv/lib/python3.7/site-packages/pipreqs/pipreqs.py", line 409, in init
    follow_links=follow_links)
  File "/Users/XXXXX/dev/XXXXX/.venv/lib/python3.7/site-packages/pipreqs/pipreqs.py", line 122, in get_all_imports
    contents = f.read()
  File "/Users/XXXXX/dev/XXXXX/.venv/bin/../lib/python3.7/codecs.py", line 322, in decode
    (result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb1 in position 81: invalid start bytedatetime64

Although pipreqs would have worked properly adding "--ignore .venv" flag, the user would not easily know where it was failing.

My environment is:

  • MacOS 10.15.2
  • Python 3.7.3
  • pipreqs==0.4.10

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.1%) to 70.766% when pulling 79a6483 on valveca-ai:master into 6ca1f42 on bndr:master.

4 similar comments
@coveralls
Copy link

Coverage Status

Coverage decreased (-0.1%) to 70.766% when pulling 79a6483 on valveca-ai:master into 6ca1f42 on bndr:master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.1%) to 70.766% when pulling 79a6483 on valveca-ai:master into 6ca1f42 on bndr:master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.1%) to 70.766% when pulling 79a6483 on valveca-ai:master into 6ca1f42 on bndr:master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.1%) to 70.766% when pulling 79a6483 on valveca-ai:master into 6ca1f42 on bndr:master.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants