Skip to content

Commit

Permalink
replace pkg_resources with importlib.metadata (#281)
Browse files Browse the repository at this point in the history
Co-authored-by: Mike Fiedler <miketheman@gmail.com>
  • Loading branch information
mistwire and miketheman authored Jun 9, 2023
1 parent 09e24c7 commit c6f1eab
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions readme_renderer/__main__.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import argparse
import email
from readme_renderer.markdown import render as render_md
from readme_renderer.rst import render as render_rst
from readme_renderer.txt import render as render_txt
import pathlib
from pkg_resources import get_distribution
from importlib.metadata import metadata
import sys
from typing import Optional, List

Expand All @@ -24,14 +23,12 @@ def main(cli_args: Optional[List[str]] = None) -> None:

content_format = args.format
if args.package:
distribution = get_distribution(args.input)
pkg_info = distribution.get_metadata(distribution.PKG_INFO)
message = email.message_from_string(pkg_info)
source = message.get_payload()
message = metadata(args.input)
source = message.get_payload() # type: ignore[attr-defined] # noqa: E501 https://peps.python.org/pep-0566/

# Infer the format of the description from package metadata.
if not content_format:
content_type = message.get("Description-Content-Type", "text/x-rst")
content_type = message.get("Description-Content-Type", "text/x-rst") # type: ignore[attr-defined] # noqa: E501 https://github.com/python/typeshed/issues/10021
if content_type == "text/x-rst":
content_format = "rst"
elif content_type == "text/markdown":
Expand Down

0 comments on commit c6f1eab

Please sign in to comment.