Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove IO parameter from setup.cfg reader #761

Merged
merged 3 commits into from
Feb 24, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 2 additions & 8 deletions src/setuptools_scm/_integration/setuptools.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,16 @@
from __future__ import annotations

import os
from typing import IO


def read_dist_name_from_setup_cfg(
input: str | os.PathLike[str] | IO[str] = "setup.cfg",
input: str | os.PathLike[str] = "setup.cfg",
) -> str | None:

# minimal effort to read dist_name off setup.cfg metadata
import configparser

parser = configparser.ConfigParser()

if isinstance(input, (os.PathLike, str)):
parser.read([input], encoding="utf-8")
else:
parser.read_file(input)

parser.read([input])
dist_name = parser.get("metadata", "name", fallback=None)
return dist_name