numpy/numpydoc

Bug located in the numpydoc-validation pre-commit hook

clatapie opened this issue · 1 comments

When running the numpydoc-validation pre-commit hook in a project, an error is raised.

The numpydoc-validation pre-commit hook has been added in a pre-commit-config.yaml file as follow:

- repo: https://github.com/numpy/numpydoc
  rev: v1.6.0
  hooks:
    - id: numpydoc-validation

However, the following error is raised when running the pre-commit command:

numpydoc-validation......................................................Failed
- hook id: numpydoc-validation
- exit code: 1

Traceback (most recent call last):
  File "C:\Users\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Users\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "C:\Users\.cache\pre-commit\repod38puuk8\py_env-python3.10\Scripts\validate-docstrings.EXE\__main__.py", line 7, in <module>
  File "C:\Users\.cache\pre-commit\repod38puuk8\py_env-python3.10\lib\site-packages\numpydoc\hooks\validate_docstrings.py", line 400, in main
    findings.extend(process_file(file, config_options))
  File "C:\Users\.cache\pre-commit\repod38puuk8\py_env-python3.10\lib\site-packages\numpydoc\hooks\validate_docstrings.py", line 339, in process_file    
    docstring_visitor.visit(module_node)
  File "C:\Users\.cache\pre-commit\repod38puuk8\py_env-python3.10\lib\site-packages\numpydoc\hooks\validate_docstrings.py", line 219, in visit
    self._get_numpydoc_issues(node)
  File "C:\Users\.cache\pre-commit\repod38puuk8\py_env-python3.10\lib\site-packages\numpydoc\hooks\validate_docstrings.py", line 188, in _get_numpydoc_issues
    report = validate.validate(
  File "C:\Users\.cache\pre-commit\repod38puuk8\py_env-python3.10\lib\site-packages\numpydoc\validate.py", line 617, in validate
    ignore_validation_comments = extract_ignore_validation_comments(
  File "C:\Users\.cache\pre-commit\repod38puuk8\py_env-python3.10\lib\site-packages\numpydoc\validate.py", line 145, in extract_ignore_validation_comments
    for token in tokenize.generate_tokens(file.readline):
  File "C:\Users\AppData\Local\Programs\Python\Python310\lib\tokenize.py", line 452, in _tokenize
    line = readline()
  File "C:\Users\AppData\Local\Programs\Python\Python310\lib\encodings\cp1252.py", line 23, in decode
    return codecs.charmap_decode(input,self.errors,decoding_table)[0]
UnicodeDecodeError: 'charmap' codec can't decode byte 0x90 in position 3194: character maps to <undefined>

Additional information

OS: Windows
Python version: 3.10.8

Local resolution of the bug

It seems to be an issue related to an encoding issue.

This was closed by #510 - thanks for reporting @clatapie !