Merge pull request #2002 from crytic/dev-fix-dataclass

Fix execution in Python 3.11
pull/2003/head
alpharush 1 year ago committed by GitHub
commit b12a167ef7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 5
      .github/workflows/ci.yml
  2. 7
      .github/workflows/test.yml
  3. 8
      slither/utils/loc.py

@ -26,6 +26,7 @@ jobs:
fail-fast: false fail-fast: false
matrix: matrix:
os: ["ubuntu-latest", "windows-2022"] os: ["ubuntu-latest", "windows-2022"]
python: ${{ (github.event_name == 'pull_request' && fromJSON('["3.8", "3.11"]')) || fromJSON('["3.8", "3.9", "3.10", "3.11"]') }}
type: ["cli", type: ["cli",
"dapp", "dapp",
"data_dependency", "data_dependency",
@ -53,10 +54,10 @@ jobs:
type: truffle type: truffle
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- name: Set up Python 3.8 - name: Set up Python ${{ matrix.python }}
uses: actions/setup-python@v3 uses: actions/setup-python@v3
with: with:
python-version: 3.8 python-version: ${{ matrix.python }}
- name: Install dependencies - name: Install dependencies
run: | run: |
pip install ".[test]" pip install ".[test]"

@ -25,12 +25,13 @@ jobs:
matrix: matrix:
os: ["ubuntu-latest", "windows-2022"] os: ["ubuntu-latest", "windows-2022"]
type: ["unit", "integration", "tool"] type: ["unit", "integration", "tool"]
python: ${{ (github.event_name == 'pull_request' && fromJSON('["3.8", "3.11"]')) || fromJSON('["3.8", "3.9", "3.10", "3.11"]') }}
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- name: Set up Python 3.8 - name: Set up Python ${{ matrix.python }}
uses: actions/setup-python@v4 uses: actions/setup-python@v4
with: with:
python-version: 3.8 python-version: ${{ matrix.python }}
cache: "pip" cache: "pip"
cache-dependency-path: setup.py cache-dependency-path: setup.py
@ -74,7 +75,7 @@ jobs:
uses: ./.github/actions/upload-coverage uses: ./.github/actions/upload-coverage
# only aggregate test coverage over linux-based tests to avoid any OS-specific filesystem information stored in # only aggregate test coverage over linux-based tests to avoid any OS-specific filesystem information stored in
# coverage metadata. # coverage metadata.
if: ${{ matrix.os == 'ubuntu-latest' }} if: ${{ matrix.os == 'ubuntu-latest' && matrix.python == '3.8' }}
coverage: coverage:
needs: needs:

@ -1,4 +1,4 @@
from dataclasses import dataclass from dataclasses import dataclass, field
from pathlib import Path from pathlib import Path
from typing import List, Tuple from typing import List, Tuple
@ -19,9 +19,9 @@ class LoCInfo:
@dataclass @dataclass
class LoC: class LoC:
src: LoCInfo = LoCInfo() src: LoCInfo = field(default_factory=LoCInfo)
dep: LoCInfo = LoCInfo() dep: LoCInfo = field(default_factory=LoCInfo)
test: LoCInfo = LoCInfo() test: LoCInfo = field(default_factory=LoCInfo)
def to_pretty_table(self) -> MyPrettyTable: def to_pretty_table(self) -> MyPrettyTable:
table = MyPrettyTable(["", "src", "dep", "test"]) table = MyPrettyTable(["", "src", "dep", "test"])

Loading…
Cancel
Save