Skip to content

Commit b3bf40e

Browse files
committed
tools: annotate return types for some functions
1 parent 91b1dfd commit b3bf40e

File tree

3 files changed

+11
-10
lines changed

3 files changed

+11
-10
lines changed

tools/create_release.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
# See the License for the specific language governing permissions and
1515
# limitations under the License.
1616

17+
from __future__ import annotations
1718
import io
1819
import sys
1920
import configparser
@@ -43,13 +44,13 @@ def __init__(self, repo: T.Optional[str], token: T.Optional[str], tag: str):
4344
self.create_source_fallback()
4445
self.create_wrap_file()
4546

46-
def read_wrap(self):
47+
def read_wrap(self) -> None:
4748
filename = Path('subprojects', f'{self.name}.wrap')
4849
self.wrap = configparser.ConfigParser(interpolation=None)
4950
self.wrap.read(filename)
5051
self.wrap_section = self.wrap[self.wrap.sections()[0]]
5152

52-
def create_patch_zip(self):
53+
def create_patch_zip(self) -> None:
5354
patch_directory = self.wrap_section.get('patch_directory')
5455
if patch_directory is None:
5556
return
@@ -99,7 +100,7 @@ def create_patch_zip(self):
99100
self.wrap_section['patch_url'] = f'https://wrapdb.mesonbuild.com/v2/{self.tag}/get_patch'
100101
self.wrap_section['patch_hash'] = patch_hash
101102

102-
def create_wrap_file(self):
103+
def create_wrap_file(self) -> None:
103104
self.wrap_section['wrapdb_version'] = self.version
104105

105106
filename = Path(self.tempdir, f'{self.name}.wrap')
@@ -117,7 +118,7 @@ def create_wrap_file(self):
117118
print(filename.read_text())
118119
self.upload(filename, 'text/plain')
119120

120-
def find_upload_url(self):
121+
def find_upload_url(self) -> None:
121122
if not self.repo or not self.token:
122123
return
123124
api = f'https://api.github.com/repos/{self.repo}/releases'
@@ -139,7 +140,7 @@ def find_upload_url(self):
139140
self.upload_url = response.json()['upload_url'].replace('{?name,label}','')
140141
print('Created release:', self.upload_url)
141142

142-
def upload(self, path: Path, mimetype: str):
143+
def upload(self, path: Path, mimetype: str) -> None:
143144
if not self.repo or not self.token:
144145
# Write files locally when not run on CI
145146
with Path('subprojects', 'packagecache', path.name).open('wb') as f:
@@ -153,7 +154,7 @@ def upload(self, path: Path, mimetype: str):
153154
response = requests.post(self.upload_url, headers=headers, params=params, data=path.read_bytes())
154155
response.raise_for_status()
155156

156-
def create_source_fallback(self):
157+
def create_source_fallback(self) -> None:
157158
response = requests.get(
158159
self.wrap_section['source_url'],
159160
headers={'User-Agent': 'wrapdb/0'},
@@ -164,7 +165,7 @@ def create_source_fallback(self):
164165
self.upload(filename, 'application/zip')
165166
self.wrap_section['source_fallback_url'] = f'https://github.com/mesonbuild/wrapdb/releases/download/{self.tag}/{filename.name}'
166167

167-
def run(repo: T.Optional[str], token: T.Optional[str]):
168+
def run(repo: T.Optional[str], token: T.Optional[str]) -> None:
168169
with open('releases.json', 'r') as f:
169170
releases = json.load(f)
170171
stdout = subprocess.check_output(['git', 'tag'])

tools/update-packagefiles.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@
2020
import shutil
2121
from pathlib import Path
2222

23-
def read_wrap(filename: Path):
23+
def read_wrap(filename: Path) -> configparser.SectionProxy:
2424
wrap = configparser.ConfigParser(interpolation=None)
2525
wrap.read(filename)
2626
return wrap[wrap.sections()[0]]
2727

28-
def read_archive_files(path: Path, base_path: Path):
28+
def read_archive_files(path: Path, base_path: Path) -> set[Path]:
2929
if path.suffix == '.zip':
3030
with zipfile.ZipFile(path, 'r') as archive:
3131
archive_files = set(base_path / i for i in archive.namelist())

tools/versions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ def get_upstream_versions() -> dict[str, str]:
9494
if len(packages['items']) < items_per_page:
9595
break
9696

97-
def sub(name, old, new):
97+
def sub(name: str, old: str, new: str) -> None:
9898
if name in versions:
9999
versions[name] = re.sub(old, new, versions[name])
100100
sub('icu', '-', '.')

0 commit comments

Comments
 (0)