PyCQA/pydocstyle

"charmap codec can't encode character in position when using" in D415 during pre-commit hook execution

betapl3b opened this issue · 0 comments

I have function docstring that uses cyrillic symbols.
For example:

    def fun1(self):
        """Cyrillic я"""
        pass

When I execute pydocstyle it works fine and gives me following FAILURE:
D415: First line should end with a period, question mark, or exclamation point (not 'я')

However, when pre-commit hook raises D415 it fails with exception:

pydocstyle...............................................................Failed
- hook id: pydocstyle
- exit code: 1

Traceback (most recent call last):
  File "C:\Users\safin.a\AppData\Local\Programs\Python\Python39\lib\runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Users\safin.a\AppData\Local\Programs\Python\Python39\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "C:\Users\safin.a\.cache\pre-commit\repo0xhe3cz2\py_env-python3.9\Scripts\pydocstyle.EXE\__main__.py", line 7, in <module>
  File "C:\Users\safin.a\.cache\pre-commit\repo0xhe3cz2\py_env-python3.9\lib\site-packages\pydocstyle\cli.py", line 75, in main
    sys.exit(run_pydocstyle())
  File "C:\Users\safin.a\.cache\pre-commit\repo0xhe3cz2\py_env-python3.9\lib\site-packages\pydocstyle\cli.py", line 61, in run_pydocstyle
    sys.stdout.write('%s\n' % error)
  File "C:\Users\safin.a\AppData\Local\Programs\Python\Python39\lib\encodings\cp1252.py", line 19, in encode
    return codecs.charmap_encode(input,self.errors,encoding_table)[0]
UnicodeEncodeError: 'charmap' codec can't encode character '\u044f' in position 158: character maps to <undefined>

Any clue what can cause this issue and what workarounds may be used to avoid this exceptions?