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

AttributeError: 'NoneType' object has no attribute 'encoding' (from_path(filename).best().encoding) #277

Open
Shuaiwu opened this issue Feb 23, 2024 · 0 comments
Labels
C: convention Relates to docstring format convention P: bug PEP 257 violation or existing functionality that doesn't work as documented U: high

Comments

@Shuaiwu
Copy link

Shuaiwu commented Feb 23, 2024

AttributeError is caught in from_path(filename).best().encoding because from_path(filename).best() can be None ref.

Traceback (most recent call last):
  File "/home/xx/miniconda3/envs/py39/lib/python3.9/runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/home/xx/miniconda3/envs/py39/lib/python3.9/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/home/xx/miniconda3/envs/py39/lib/python3.9/site-packages/docformatter/__main__.py", line 155, in <module>
    sys.exit(main())
  File "/home/xx/miniconda3/envs/py39/lib/python3.9/site-packages/docformatter/__main__.py", line 144, in main
    return _main(
  File "/home/xx/miniconda3/envs/py39/lib/python3.9/site-packages/docformatter/__main__.py", line 134, in _main
    return formator.do_format_files()
  File "/home/xx/miniconda3/envs/py39/lib/python3.9/site-packages/docformatter/format.py", line 257, in do_format_files
    result = self._do_format_file(filename)
  File "/home/xx/miniconda3/envs/py39/lib/python3.9/site-packages/docformatter/format.py", line 286, in _do_format_file
    self.encodor.do_detect_encoding(filename)
  File "/home/xx/miniconda3/envs/py39/lib/python3.9/site-packages/docformatter/encode.py", line 59, in do_detect_encoding
    self.encoding = from_path(filename).best().encoding
AttributeError: 'NoneType' object has no attribute 'encoding'

Version

Python 3.9.17
charset-normalizer   3.3.2
docformatter 1.7.5
@github-actions github-actions bot added the fresh This is a new issue label Feb 23, 2024
@weibullguy weibullguy added P: bug PEP 257 violation or existing functionality that doesn't work as documented C: convention Relates to docstring format convention and removed fresh This is a new issue labels Jul 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C: convention Relates to docstring format convention P: bug PEP 257 violation or existing functionality that doesn't work as documented U: high
Projects
None yet
Development

No branches or pull requests

2 participants