Skip to content

Commit a84d908

Browse files
committed
Fix broken type hints for nested functions
1 parent 98574ce commit a84d908

File tree

2 files changed

+20
-22
lines changed

2 files changed

+20
-22
lines changed

nimporter/lib.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ def ensure_nimpy() -> None:
218218
ic()
219219

220220
try:
221-
run_process('nimble')
221+
run_process(['nimble'])
222222
except FileNotFoundError as e:
223223
error = CompilationFailedException('Nim not installed or not on path')
224224
raise error from e

nimporter/nexporter.py

+19-21
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import os
2+
import re
23
import sys
34
from typing import *
45
from pathlib import Path
@@ -257,27 +258,6 @@ def compile_extensions_to_c(platforms: List[str], root: Path) -> None:
257258
return
258259

259260

260-
def _is_valid_identifier(string: str) -> Union[Match[str], None, bool]:
261-
import re
262-
match = re.search('^[A-Za-z_][A-Z-a-z0-9_\\-]*', string)
263-
return match and len(match.string) == len(string)
264-
265-
266-
def _is_semver(string: str) -> bool:
267-
try:
268-
lib_name, lib_version = string.rsplit('-', maxsplit=1)
269-
assert _is_valid_identifier(lib_name)
270-
271-
major, minor, patch = lib_version.split('.')
272-
assert major.isdigit()
273-
assert minor.isdigit()
274-
assert patch.isdigit()
275-
276-
return True
277-
except:
278-
return False
279-
280-
281261
def prevent_win32_max_path_length_error(path: Path) -> None:
282262
"""
283263
Nim generates C files that contain `@` symbols to encode the original path
@@ -296,6 +276,24 @@ def prevent_win32_max_path_length_error(path: Path) -> None:
296276
That's a lot less characters!
297277
"""
298278

279+
def _is_valid_identifier(string: str) -> Union[re.Match[str], None, bool]:
280+
match = re.search('^[A-Za-z_][A-Z-a-z0-9_\\-]*', string)
281+
return match and len(match.string) == len(string)
282+
283+
def _is_semver(string: str) -> bool:
284+
try:
285+
lib_name, lib_version = string.rsplit('-', maxsplit=1)
286+
assert _is_valid_identifier(lib_name)
287+
288+
major, minor, patch = lib_version.split('.')
289+
assert major.isdigit()
290+
assert minor.isdigit()
291+
assert patch.isdigit()
292+
293+
return True
294+
except:
295+
return False
296+
299297
for item in path.iterdir():
300298
if item.is_file() and item.name.startswith('@m'):
301299

0 commit comments

Comments
 (0)