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

fix: issue where always warned #164

Merged
merged 1 commit into from
Feb 5, 2024
Merged
Show file tree
Hide file tree
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
13 changes: 9 additions & 4 deletions solcx/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -489,8 +489,9 @@ def install_solc(
version, filename, show_progress, solcx_binary_path=solcx_binary_path
)

base_version = version if isinstance(version, str) else version.base_version
try:
_validate_installation(version, solcx_binary_path=solcx_binary_path)
_validate_installation(Version(base_version), solcx_binary_path=solcx_binary_path)
except SolcInstallationError as exc:
if os_name != "windows":
exc.args = (
Expand Down Expand Up @@ -703,16 +704,20 @@ def _validate_installation(version: Version, solcx_binary_path: Union[Path, str,
installed_version_clean = Version(
Version(installed_version.replace("-nightly", "")).base_version
)
if installed_version_clean.base_version != version.base_version:
base_version = version if isinstance(version, str) else version.base_version
if installed_version_clean.base_version != base_version:
# Without the nightly suffix, it should be the same!
_unlink_solc(binary_path)
raise UnexpectedVersionError(
f"Attempted to install solc v{version}, but got solc v{installed_version}"
)
if installed_version not in (version.base_version, f"{version}"):
if installed_version_clean not in (
Version(base_version),
f"{base_version}",
) or installed_version.endswith("-nightly"):
# If it does have the nightly suffix, then only warn.
warnings.warn(
f"Installed solc version is v{installed_version}, expecting v{version.base_version}",
f"Installed solc version is v{installed_version_clean}, expecting v{base_version}",
UnexpectedVersionWarning,
)

Expand Down
7 changes: 6 additions & 1 deletion tests/install/test_install.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import warnings

import pytest

import solcx
Expand All @@ -23,7 +25,10 @@ def test_install_unknown_version():

@pytest.mark.skipif("'--no-install' in sys.argv")
def test_progress_bar(nosolc):
assert solcx.install_solc("0.6.9", show_progress=True).base_version == "0.6.9"
# There should be no warnings!
with warnings.catch_warnings():
warnings.simplefilter("error")
assert solcx.install_solc("0.6.9", show_progress=True).base_version == "0.6.9"


def test_environment_var_path(monkeypatch, tmp_path):
Expand Down