>>> import importlib.metadata
>>> importlib.metadata.metadata("pyright")
<importlib.metadata._adapters.Message object at 0x000005DBF8597690>
>>> str(importlib.metadata.metadata("pyright"))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
str(importlib.metadata.metadata("pyright"))
~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Program Files\Python314\Lib\email\message.py", line 171, in __str__
return self.as_string()
~~~~~~~~~~~~~~^^
File "C:\Program Files\Python314\Lib\email\message.py", line 194, in as_string
g.flatten(self, unixfrom=unixfrom)
~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Program Files\Python314\Lib\email\generator.py", line 118, in flatten
self._write(msg)
~~~~~~~~~~~^^^^^
File "C:\Program Files\Python314\Lib\email\generator.py", line 201, in _write
self._write_headers(msg)
~~~~~~~~~~~~~~~~~~~^^^^^
File "C:\Program Files\Python314\Lib\email\generator.py", line 228, in _write_headers
folded = self.policy.fold(h, v)
File "C:\Program Files\Python314\Lib\email\_policybase.py", line 344, in fold
return self._fold(name, value, sanitize=True)
~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Program Files\Python314\Lib\email\_policybase.py", line 387, in _fold
parts.append(h.encode(linesep=self.linesep, maxlinelen=maxlinelen))
~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Program Files\Python314\Lib\email\header.py", line 394, in encode
raise HeaderParseError("header value appears to contain "
"an embedded header: {!r}".format(value))
email.errors.HeaderParseError: header value appears to contain an embedded header: '# Pyright for Python\n[](https://pepy.tech/project/pyright)\n\n\n> This project is not affiliated with Microsoft in any way, shape, or form\nPyright for Python is a Python command-line wrapper over [pyright](https://github.com/microsoft/pyright), a static type checker for Python.\n## Installation\nUse the package manager [pip](https://pip.pypa.io/en/stable/) to install pyright.\n```bash\npip install pyright\n```\n> [!TIP]\n> It\'s highly recommended to install `pyright` with the `nodejs` extra which uses [`nodejs-wheel`](https://pypi.org/project/nodejs-wheel-binaries/) to\n> download Node.js binaries as it is more reliable than the default [`nodeenv`](https://pypi.org/project/nodeenv/) solution.\n>\n> ```bash\n> pip install pyright[nodejs]\n> ```\n## Usage\nPyright can be invoked using two different methods\n```bash\npyright --help\n```\nor\n```bash\npython3 -m pyright --help\n```\nPyright for Python should work exactly the same as pyright does, see the [pyright documentation](https://github.com/microsoft/pyright/blob/main/docs/getting-started.md) for details on how to make use of pyright.\n### Pre-commit\nYou can also setup pyright to run automatically before each commit by setting up [pre-commit](https://pre-commit.com) and registering pyright in your `.pre-commit-config.yaml` file\n```yaml\nrepos:\n - repo: https://github.com/RobertCraigie/pyright-python\n rev: v1.1.409\n hooks:\n - id: pyright\n```\nPre-commit will install pyright-python in its own virtual environment which can cause pyright to not be able to detect your installed dependencies.\nTo fix this you can either [tell pre-commit](https://pre-commit.com/#config-additional_dependencies) to also install those dependencies or explicitly tell pyright which virtual environment to use by updating your [pyright configuration file](https://github.com/microsoft/pyright/blob/main/docs/configuration.md):\n```toml\n[tool.pyright]\n# ...\nvenvPath = "."\nvenv = ".venv"\n```\n## Motivation\n[Pyright](https://github.com/microsoft/pyright) is written in TypeScript, requiring node to be installed, and is normally installed with npm. This could be an entry barrier for some Python developers as they may not have node or npm installed on their machine; I wanted to make pyright as easy to install as any normal Python package.\n## How Pyright for Python Works\nThis project works by first checking if node is in the `PATH`. If it is not, then we download node at runtime using [nodeenv](https://github.com/ekalinin/nodeenv), then install the pyright npm package using `npm` and finally, run the downloaded JS with `node`.\n## Automatically keeping pyright up to date\nBy default Pyright for Python is set to target a specific pyright version and new releases will be automatically created whenever a new pyright version is released. It is highly recommended to use an automatic dependency update tool such as [dependabot](https://docs.github.com/en/code-security/supply-chain-security/managing-vulnerabilities-in-your-projects-dependencies/configuring-dependabot-security-updates).\nIf you would rather not have to update your installation every time a new pyright release is created then you can automatically use the latest available pyright version by setting the environment variable `PYRIGHT_PYTHON_FORCE_VERSION` to `latest`.\n## Configuration\nYou can configure Pyright for Python using environment variables.\n### Debugging\nSet `PYRIGHT_PYTHON_DEBUG` to any value.\n### Modify Pyright Version\nSet `PYRIGHT_PYTHON_FORCE_VERSION` to the desired version, e.g. `1.1.156`, `latest`\n### Keeping Pyright and Pylance in sync\nSet `PYRIGHT_PYTHON_PYLANCE_VERSION` to your Pylance version, e.g. `2023.11.11`, `latest-release`, `latest-prerelease`. The corresponding Pyright version will be used. See [Pylance\'s changelog](https://github.com/microsoft/pylance-release/blob/main/CHANGELOG.md) for details on recent releases. Note that `PYRIGHT_PYTHON_FORCE_VERSION` takes precedence over `PYRIGHT_PYTHON_PYLANCE_VERSION`, so you\'ll want to set one or the other, not both.\n### Show NPM logs\nBy default, Pyright for Python disables npm error messages, if you want to display the npm error messages then set `PYRIGHT_PYTHON_VERBOSE` to any truthy value.\n### Modify NPM Package Location\nPyright for Python will resolve the root cache directory by checking the following environment variables, in order:\n- `PYRIGHT_PYTHON_CACHE_DIR`\n- `XDG_CACHE_HOME`\nIf neither of them are set it defaults to `~/.cache`\n### Force Node Env\nSet `PYRIGHT_PYTHON_GLOBAL_NODE` to any non-truthy value, i.e. anything apart from 1, t, on, or true.\ne.g. `off`\nYou can optionally choose the version of node used by setting `PYRIGHT_PYTHON_NODE_VERSION` to the desired version\n### Modify Node Env Location\nSet `PYRIGHT_PYTHON_ENV_DIR` to a valid [nodeenv](https://github.com/ekalinin/nodeenv) directory. e.g. `~/.cache/nodeenv`\n### Ignore Warnings\nSet `PYRIGHT_PYTHON_IGNORE_WARNINGS` to a truthy value, e.g. 1, t, on, or true.\nPyright for Python will print warnings for the following case(s)\n- There is a new Pyright version available.\n## Contributing\nAll pull requests are welcome.\n## License\n[MIT](https://choosealicense.com/licenses/mit/)'
>>>
Bug report
Bug description:
Unable to parse the metadata of many packages that have a Description field.
Packages I tested:
pyright,pytest,pyyaml,requests,ruff,urllib3,poethepoet. Among them,pyright,pytest,pyinstaller, andpyyamlare problematic.pyright
pytest
pyyaml
pyinstaller
CPython versions tested on:
3.14
Operating systems tested on:
Windows