Skip to content

Commit e6b2f49

Browse files
authored
Merge pull request #532 from crytic/fix/vyper-hard-error
fix(vyper): only raise InvalidCompilation on hard errors
2 parents eef5aa1 + 2ba56ed commit e6b2f49

File tree

3 files changed

+26
-9
lines changed

3 files changed

+26
-9
lines changed

.github/workflows/ci.yml

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ jobs:
2222
fail-fast: false
2323
matrix:
2424
os: ["ubuntu-latest", "windows-2022"]
25+
python: ${{ (github.event_name == 'pull_request' && fromJSON('["3.8", "3.12"]')) || fromJSON('["3.8", "3.9", "3.10", "3.11", "3.12"]') }}
2526
type: ["brownie", "buidler", "dapp", "embark", "hardhat", "solc", "truffle", "waffle", "foundry", "standard", "vyper", "solc_multi_file", "hardhat_multi_file"]
2627
exclude:
2728
# Currently broken, tries to pull git:// which is blocked by GH
@@ -32,6 +33,12 @@ jobs:
3233
# Explore foundry support in windows
3334
- os: windows-2022
3435
type: foundry
36+
# brownie does not install correctly with Python 3.12
37+
- python: 3.12
38+
type: brownie
39+
# TODO: review failure executing npx on Windows
40+
- os: windows-2022
41+
python: 3.12
3542
steps:
3643
- uses: actions/checkout@v4
3744
- name: Set up shell
@@ -43,15 +50,14 @@ jobs:
4350
uses: actions/setup-node@v4
4451
with:
4552
node-version: 18.15
46-
- name: Set up Python 3.8
53+
- name: Set up Python ${{ matrix.python }}
4754
uses: actions/setup-python@v5
4855
with:
49-
python-version: 3.8
56+
python-version: ${{ matrix.python }}
5057
- name: Install dependencies
5158
run: |
52-
pip install "solc-select>=v1.0.0b1"
53-
solc-select use 0.5.7 --always-install
5459
pip install .
60+
solc-select use 0.5.7 --always-install
5561
- name: Set up nix
5662
if: matrix.type == 'dapp'
5763
uses: cachix/install-nix-action@v24

crytic_compile/__main__.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,13 @@
22
This is the Slither cli script
33
"""
44
import argparse
5+
from importlib.metadata import version
56
import json
67
import logging
78
import os
89
import sys
910
from typing import TYPE_CHECKING, Any, Optional
1011

11-
from pkg_resources import require
12-
1312
from crytic_compile.crytic_compile import compile_all, get_platforms
1413
from crytic_compile.cryticparser import DEFAULTS_FLAG_IN_CONFIG, cryticparser
1514
from crytic_compile.platform import InvalidCompilation
@@ -109,7 +108,7 @@ def parse_args() -> argparse.Namespace:
109108
parser.add_argument(
110109
"--version",
111110
help="displays the current version",
112-
version=require("crytic-compile")[0].version,
111+
version=version("crytic-compile"),
113112
action="version",
114113
)
115114

crytic_compile/platform/vyper.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,9 +206,21 @@ def _run_vyper_standard_json(
206206
) # convert bytestrings to unicode strings
207207

208208
vyper_standard_output = json.loads(stdout)
209+
209210
if "errors" in vyper_standard_output:
210-
# TODO format errors
211-
raise InvalidCompilation(vyper_standard_output["errors"])
211+
212+
has_errors = False
213+
for diagnostic in vyper_standard_output["errors"]:
214+
215+
if diagnostic["severity"] == "warning":
216+
continue
217+
218+
msg = diagnostic.get("formattedMessage", diagnostic["message"])
219+
LOGGER.error(msg)
220+
has_errors = True
221+
222+
if has_errors:
223+
raise InvalidCompilation("Vyper compilation errored")
212224

213225
return vyper_standard_output
214226

0 commit comments

Comments
 (0)