numpy / numpy/numpydoc

UnicodeDecodeError

Open
#546 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
355
Forks
181
Avg merge
1d 9h
Merged PRs (30d)
3

Description

I am getting this error when running the hook

-   repo: https://github.com/numpy/numpydoc
    rev: v1.7.0
    hooks:
      - id: numpydoc-validation
        exclude: (test|docs|labs|alant-st|apps)/.*

I am not really sure if it is my code that is causing this error, or the hook itself.

C:\Users\abed\.cache\pre-commit\repoh5hb9w09\py_env-python3.12\Lib\site-packages\numpydoc\docscrape.py:456: UserWarning: Unknown section Return
  warn(msg)
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "C:\Users\abed\.cache\pre-commit\repoh5hb9w09\py_env-python3.12\Scripts\validate-docstrings.EXE\__main__.py", line 7, in <module>
  File "C:\Users\abed\.cache\pre-commit\repoh5hb9w09\py_env-python3.12\Lib\site-packages\numpydoc\hooks\validate_docstrings.py", line 400, in main
    findings.extend(process_file(file, config_options))
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\abed\.cache\pre-commit\repoh5hb9w09\py_env-python3.12\Lib\site-packages\numpydoc\hooks\validate_docstrings.py", line 336, in process_file
    module_node = ast.parse(file.read(), filepath)
                            ^^^^^^^^^^^
  File "C:\Users\abed\miniconda3\envs\adev\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 0x9d in position 7689: character maps to <undefined>

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the Windows/Python 3.12 hook failure and inspect numpydoc/hooks/validate_docstrings.py around process_file, where file.read() raises the decoding error. Check the related warning in numpydoc/docscrape.py and existing tests for validation hooks. Done means the reported encoding failure is handled or clearly diagnosed without regressing document validation.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.