Skip to content

Commit 32dca63

Browse files
authored
Remove wildcard imports, other touchups (#63)
Basically a combination of autoflake, pyupgrade and isort
1 parent e950eb9 commit 32dca63

File tree

7 files changed

+19
-16
lines changed

7 files changed

+19
-16
lines changed

data/empty_package/setup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import sys
2+
23
from setuptools import setup
34

45
increment = int(sys.argv.pop())

stub_uploader/build_wheel.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,14 @@
2323
import subprocess
2424
import tempfile
2525
from textwrap import dedent
26-
from typing import Dict, List, Optional
26+
from typing import Optional
2727

28-
from stub_uploader.const import *
28+
from stub_uploader.const import (
29+
CHANGELOG_PATH,
30+
META,
31+
TESTS_NAMESPACE,
32+
THIRD_PARTY_NAMESPACE,
33+
)
2934
from stub_uploader.metadata import Metadata, read_metadata
3035

3136
CHANGELOG = "CHANGELOG.md"
@@ -99,7 +104,7 @@ def __init__(self, typeshed_dir: str, distribution: str) -> None:
99104
self.stub_dir = os.path.join(typeshed_dir, THIRD_PARTY_NAMESPACE, distribution)
100105

101106

102-
def find_stub_files(top: str) -> List[str]:
107+
def find_stub_files(top: str) -> list[str]:
103108
"""Find all stub files for a given package, relative to package root.
104109
105110
Raise if we find any unknown file extensions during collection.
@@ -169,7 +174,7 @@ def copy_changelog(distribution: str, dst: str) -> None:
169174
pass # Ignore missing changelogs
170175

171176

172-
def collect_setup_entries(base_dir: str) -> Dict[str, List[str]]:
177+
def collect_setup_entries(base_dir: str) -> dict[str, list[str]]:
173178
"""Generate package data for a setuptools.setup() call.
174179
175180
This reflects the transformations done during copying in copy_stubs().
@@ -263,7 +268,7 @@ def main(
263268
commit = subprocess.run(
264269
["git", "rev-parse", "HEAD"],
265270
capture_output=True,
266-
universal_newlines=True,
271+
text=True,
267272
cwd=typeshed_dir,
268273
).stdout.strip()
269274
metadata = read_metadata(typeshed_dir, distribution)

stub_uploader/get_changed.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,14 @@
1111
import os
1212
import subprocess
1313

14-
from typing import List
1514

16-
17-
def main(typeshed_dir: str, commit: str) -> List[str]:
15+
def main(typeshed_dir: str, commit: str) -> list[str]:
1816
"""List all distributions that changed since commit."""
1917
assert typeshed_dir.endswith(os.sep + "typeshed")
2018
git = subprocess.run(
2119
["git", "diff", "--no-renames", "--name-only", "HEAD", commit],
2220
capture_output=True,
23-
universal_newlines=True,
21+
text=True,
2422
cwd=typeshed_dir,
2523
check=True,
2624
)

stub_uploader/get_version.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,15 @@
1212

1313
from __future__ import annotations
1414

15-
from typing import Any, Union
15+
from typing import Any
1616

1717
import requests
1818
from packaging.specifiers import SpecifierSet
1919
from packaging.version import Version
2020
from requests.adapters import HTTPAdapter
2121
from urllib3.util.retry import Retry
2222

23-
from stub_uploader.const import *
23+
from stub_uploader.const import TYPES_PREFIX
2424
from stub_uploader.metadata import Metadata
2525

2626
URL_TEMPLATE = "https://pypi.org/pypi/{}/json"

stub_uploader/metadata.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
import graphlib
55
import os
66
import re
7-
from typing import Any, Dict, Iterator, Optional
7+
from typing import Any, Optional
8+
from collections.abc import Iterator
89

910
import requests
1011
import tomli
@@ -18,7 +19,7 @@ class InvalidRequires(Exception):
1819

1920

2021
class Metadata:
21-
def __init__(self, distribution: str, data: Dict[str, Any]):
22+
def __init__(self, distribution: str, data: dict[str, Any]):
2223
assert not distribution.startswith(TYPES_PREFIX)
2324
self._alleged_upstream_distribution = distribution
2425
self.data = data

stub_uploader/update_changelog.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,10 @@
99
import os
1010
import re
1111
import subprocess
12-
from dataclasses import dataclass
1312
from pathlib import Path
1413

1514
from stub_uploader.const import CHANGELOG_PATH
1615

17-
1816
THIRD_PARTY_NAMESPACE = "stubs"
1917

2018

tests/test_unit.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,5 +134,5 @@ def test_uploaded_packages() -> None:
134134
up.add("six")
135135
assert up.read() == {"types-sqlalchemy", "types-six"}
136136

137-
with open(file_path, "r") as f:
137+
with open(file_path) as f:
138138
assert f.read() == "types-SqLaLcHeMy\ntypes-six"

0 commit comments

Comments
 (0)