Skip to content

Commit 6abc325

Browse files
authored
feat: select_pragma_version
2 parents 0829b29 + 400ae8f commit 6abc325

File tree

5 files changed

+16
-10
lines changed

5 files changed

+16
-10
lines changed

.pre-commit-config.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ repos:
44
hooks:
55
- id: check-yaml
66
- repo: https://github.com/psf/black
7-
rev: 23.10.1
7+
rev: 23.11.0
88
hooks:
99
- id: black
1010
name: fmt

setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"hypothesis>=6.2.0,<7.0", # Strategy-based fuzzer
1313
],
1414
"lint": [
15-
"black>=23.10.1,<24", # auto-formatter and linter
15+
"black>=23.11.0,<24", # auto-formatter and linter
1616
"mypy>=1.6.1,<2", # Static type analyzer
1717
"types-setuptools", # Needed due to mypy typeshed
1818
"types-requests", # Needed due to mypy typeshed

solcx/install.py

+14-3
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,18 @@ def set_solc_version(
227227
LOGGER.info(f"Using solc version {version}")
228228

229229

230-
def _select_pragma_version(pragma_string: str, version_list: List[Version]) -> Optional[Version]:
230+
def select_pragma_version(pragma_string: str, version_list: List[Version]) -> Optional[Version]:
231+
"""
232+
Get a matching version from the given pragma string and a version list.
233+
234+
Args:
235+
pragma_string (str): A pragma str.
236+
version_list (List[Version]): A list of valid versions.
237+
238+
Returns:
239+
Optional[Version]: A selected version from the given list.
240+
"""
241+
231242
comparator_set_range = pragma_string.replace(" ", "").split("||")
232243
comparator_regex = re.compile(r"(([<>]?=?|\^)\d+\.\d+\.\d+)")
233244
version = None
@@ -276,7 +287,7 @@ def set_solc_version_pragma(
276287
Version: The new active `solc` version.
277288
"""
278289
installed_versions = get_installed_solc_versions()
279-
if not (version := _select_pragma_version(pragma_string, installed_versions)):
290+
if not (version := select_pragma_version(pragma_string, installed_versions)):
280291
raise SolcNotInstalled(
281292
f"No compatible solc version installed."
282293
f" Use solcx.install_solc_version_pragma('{pragma_string}') to install."
@@ -316,7 +327,7 @@ def install_solc_pragma(
316327
"""
317328

318329
installed_versions = get_installable_solc_versions()
319-
if version := _select_pragma_version(pragma_string, installed_versions):
330+
if version := select_pragma_version(pragma_string, installed_versions):
320331
install_solc(version, show_progress=show_progress, solcx_binary_path=solcx_binary_path)
321332
else:
322333
raise UnsupportedVersionError(

solcx/py.typed

Whitespace-only changes.

solcx/wrapper.py

-5
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,6 @@
1212
VERSION_REGEX = r"(\d+\.\d+\.\d+)(?:-nightly.\d+.\d+.\d+|)(\+commit.\w+)"
1313

1414

15-
def _get_solc_version(solc_binary: Union[Path, str], with_commit_hash: bool = False) -> Version:
16-
# TODO: Remove around 1.2.0. Was private, kept to prevent accidentally breaking downstream.
17-
return get_solc_version(solc_binary, with_commit_hash=with_commit_hash)
18-
19-
2015
def get_version_str_from_solc_binary(solc_binary: Union[Path, str]) -> str:
2116
stdout_data = subprocess.check_output([str(solc_binary), "--version"], encoding="utf8")
2217
if not (match := next(re.finditer(VERSION_REGEX, stdout_data), None)):

0 commit comments

Comments
 (0)