UnicodeDecodeError

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

Nobody has claimed this yet.

Assessment

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

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.

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>
Dominant language
Python
Stars
354
Forks
185
Avg merge
4m
Merged PRs (30d)
1

Getting set up

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.

More from numpy/numpydoc

All issues in numpy/numpydoc

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.