Skip to content
Draft
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
7 changes: 7 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,10 @@ repos:
rev: 22.3.0
hooks:
- id: black
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.9.7
hooks:
# Run the linter.
- id: ruff
# The formatter could be run in the future
#- id: ruff-format
8 changes: 3 additions & 5 deletions doc/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
import os
import sys
from datetime import datetime
from importlib import util as importlib_util

import jsonschema2md

import fusesoc
from fusesoc.capi2.json_schema import capi2_schema
from fusesoc.utils import yaml_read

Expand Down Expand Up @@ -109,11 +109,9 @@
# or
# - apt-get install python-sphinx-rtd-theme

try:
import sphinx_rtd_theme

if importlib_util.find_spec("sphinx_rtd_theme") is not None:
html_theme = "sphinx_rtd_theme"
except ImportError:
else:
sys.stderr.write(
"Warning: The Sphinx 'sphinx_rtd_theme' HTML theme was "
+ "not found. Make sure you have the theme installed to produce pretty "
Expand Down
1 change: 0 additions & 1 deletion fusesoc/capi2/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,6 @@ def _parse_param(flags, name, core_param):
# ...or in any of its dependencies
elif p in ext_parameters:
parameters[p] = ext_parameters[p]
datatype = parameters[p]["datatype"]

else:
raise SyntaxError(
Expand Down
4 changes: 2 additions & 2 deletions fusesoc/coremanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ def eq_vln(this, that):
transaction = solver.solve(request)
except SatisfiabilityError as e:
raise DependencyError(top_core.name, msg=e.unsat.to_string(pool))
except NoPackageFound as e:
except NoPackageFound:
raise DependencyError(top_core.name)

virtual_selection = {}
Expand Down Expand Up @@ -376,7 +376,7 @@ def _detect_capi_version(self, core_file) -> int:
core_file
)
)
except Exception as error:
except Exception:
error_msg = f"Unable to determine CAPI version from core file {core_file}"
logger.warning(error_msg)
return -1
Expand Down
8 changes: 1 addition & 7 deletions fusesoc/edalizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

from fusesoc import utils
from fusesoc.capi2.coreparser import Core2Parser
from fusesoc.coremanager import DependencyError
from fusesoc.utils import merge_dict
from fusesoc.vlnv import Vlnv

Expand Down Expand Up @@ -338,7 +337,7 @@ def _build_parser(self, backend_class, edam):
default = [
typedict[param["datatype"]]["type"](param["default"])
]
except KeyError as e:
except KeyError:
pass
try:
param_groups[_paramtype].add_argument(
Expand Down Expand Up @@ -622,11 +621,6 @@ def is_generator_cacheable(self):
def is_cacheable(self):
return self.is_input_cacheable() or self.is_generator_cacheable()

def acquire_cache_lock(self):
have_lock = False
# while not have_lock:
# if

def generate(self):
"""Run a parametrized generator

Expand Down
1 change: 0 additions & 1 deletion fusesoc/filters/splitlib.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import logging
import os

logger = logging.getLogger(__name__)

Expand Down
6 changes: 3 additions & 3 deletions fusesoc/fusesoc.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@
import os
from importlib import import_module

from fusesoc.config import Config
from fusesoc.coremanager import CoreManager, DependencyError
from fusesoc.edalizer import Edalizer
from fusesoc.librarymanager import Library, LibraryManager
from fusesoc.utils import Launcher, setup_logging, yaml_fread
from fusesoc.utils import setup_logging, yaml_fread
from fusesoc.vlnv import Vlnv

try:
Expand All @@ -36,7 +35,7 @@ def _register_libraries(self):
for library in self.config.libraries + cores_root_libs:
try:
self.add_library(library)
except (RuntimeError, OSError) as e:
except (RuntimeError, OSError):
try:
temporary_lm = LibraryManager(self.config.library_root)
# try to initialize library
Expand Down Expand Up @@ -146,6 +145,7 @@ def get_backend(self, core, flags, backendargs=[]):
try:
backend_class = get_edatool(flags["tool"])
except ImportError:
tool = flags.setdefault("tool", "")
raise RuntimeError(f"Backend {tool!r} not found")

edalizer = Edalizer(
Expand Down
2 changes: 1 addition & 1 deletion fusesoc/librarymanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def l(s):
logger.info(l(f"{self.location} does not exist. Trying a checkout"))
try:
provider.init_library(self)
except RuntimeError as e:
except RuntimeError:
# Keep old behavior of logging a warning if there is a library
# in `fusesoc.conf`, but the directory does not exist for some
# reason and it could not be initialized.
Expand Down
1 change: 0 additions & 1 deletion fusesoc/parser/coreparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
# SPDX-License-Identifier: BSD-2-Clause

import fastjsonschema
import yaml

from fusesoc import utils

Expand Down
2 changes: 0 additions & 2 deletions fusesoc/provider/git.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
# SPDX-License-Identifier: BSD-2-Clause

import logging
import os.path
import shutil
import subprocess

from fusesoc.provider.provider import Provider
Expand Down
1 change: 0 additions & 1 deletion fusesoc/provider/opencores.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
# SPDX-License-Identifier: BSD-2-Clause

import logging
import sys

from fusesoc.provider.provider import Provider
from fusesoc.utils import Launcher, cygpath, is_mingw
Expand Down
19 changes: 19 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,22 @@ envlist = py3
deps = pytest
commands = pytest
"""

[tool.ruff]
line-length = 88
indent-width = 4

target-version = "py37"

[tool.ruff.lint]
ignore = [
"E711",
"E712",
"E713",
"E714",
"E721",
"E722",
"E741",
"E743",
"E402",
]
7 changes: 2 additions & 5 deletions tests/test_capi2.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,13 @@ def test_files_out_of_hierarchy():

def test_empty_core():
import os
import tempfile

from fusesoc.capi2.coreparser import Core2Parser
from fusesoc.core import Core

core_file = os.path.join(tests_dir, "capi2_cores", "misc", "empty.core")
with pytest.raises(SyntaxError) as excinfo:
core = Core(Core2Parser(), core_file)
Core(Core2Parser(), core_file)
assert "Error validating" in str(excinfo.value)


Expand Down Expand Up @@ -127,8 +126,6 @@ def test_capi2_export_no_overwrite():
"vpifile",
]

result = []

# Export and check all dst files are equal to src files
core.export(export_root)
for f in expected:
Expand Down Expand Up @@ -282,7 +279,7 @@ def test_capi2_type_check():
core_file = os.path.join(tests_dir, "capi2_cores", "misc", "typecheck.core")

with pytest.raises(SyntaxError) as excinfo:
core = Core(Core2Parser(), core_file)
Core(Core2Parser(), core_file)
assert "Error validating" in str(excinfo.value)


Expand Down
23 changes: 9 additions & 14 deletions tests/test_libraries.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
import shutil
import subprocess
import tempfile
from textwrap import dedent
from argparse import Namespace

from test_common import cache_root, cores_root, library_root

from fusesoc.config import Config
from fusesoc.fusesoc import Fusesoc
from fusesoc.librarymanager import Library

build_root = "test_build_root"

Expand Down Expand Up @@ -61,7 +61,6 @@
import tempfile

from fusesoc.coremanager import CoreManager
from fusesoc.librarymanager import LibraryManager
from fusesoc.main import add_library

with tempfile.TemporaryDirectory() as td:
Expand Down Expand Up @@ -136,21 +135,21 @@
vars(args)["sync-version"] = "capi2"
args.location = None

expected = """[library.fusesoc-cores]
location = fusesoc_libraries/fusesoc-cores
sync-uri = https://github.com/fusesoc/fusesoc-cores
sync-version = capi2
sync-type = git
auto-sync = true""".format(
cm._lm.library_root
)
expected = dedent("""
[library.fusesoc-cores]
location = fusesoc_libraries/fusesoc-cores
sync-uri = https://github.com/fusesoc/fusesoc-cores
sync-version = capi2
sync-type = git
auto-sync = true
""")

add_library(cm, args)

tcf.seek(0)
result = tcf.read().strip()

assert expected == result

Check failure on line 152 in tests/test_libraries.py

View workflow job for this annotation

GitHub Actions / 🐧 ubuntu-20.04 | 3.7

test_library_add AssertionError: assert '\n[library.fusesoc-cores]\nlocation = fusesoc_libraries/fusesoc-cores\nsync-uri = https://github.com/fusesoc/fusesoc-cores\nsync-version = capi2\nsync-type = git\nauto-sync = true\n' == '[library.fusesoc-cores]\nlocation = fusesoc_libraries/fusesoc-cores\nsync-uri = https://github.com/fusesoc/fusesoc-cores\nsync-version = capi2\nsync-type = git\nauto-sync = true' + [library.fusesoc-cores] location = fusesoc_libraries/fusesoc-cores sync-uri = https://github.com/fusesoc/fusesoc-cores sync-version = capi2 sync-type = git - auto-sync = true + auto-sync = true ? +

Check failure on line 152 in tests/test_libraries.py

View workflow job for this annotation

GitHub Actions / 🐧 ubuntu-20.04 | 3.8

test_library_add AssertionError: assert '\n[library.fusesoc-cores]\nlocation = fusesoc_libraries/fusesoc-cores\nsync-uri = https://github.com/fusesoc/fusesoc-cores\nsync-version = capi2\nsync-type = git\nauto-sync = true\n' == '[library.fusesoc-cores]\nlocation = fusesoc_libraries/fusesoc-cores\nsync-uri = https://github.com/fusesoc/fusesoc-cores\nsync-version = capi2\nsync-type = git\nauto-sync = true' + [library.fusesoc-cores] location = fusesoc_libraries/fusesoc-cores sync-uri = https://github.com/fusesoc/fusesoc-cores sync-version = capi2 sync-type = git - auto-sync = true + auto-sync = true ? +

Check failure on line 152 in tests/test_libraries.py

View workflow job for this annotation

GitHub Actions / 🐧 ubuntu-20.04 | 3.9

test_library_add AssertionError: assert '\n[library.fusesoc-cores]\nlocation = fusesoc_libraries/fusesoc-cores\nsync-uri = https://github.com/fusesoc/fusesoc-cores\nsync-version = capi2\nsync-type = git\nauto-sync = true\n' == '[library.fusesoc-cores]\nlocation = fusesoc_libraries/fusesoc-cores\nsync-uri = https://github.com/fusesoc/fusesoc-cores\nsync-version = capi2\nsync-type = git\nauto-sync = true' + [library.fusesoc-cores] location = fusesoc_libraries/fusesoc-cores sync-uri = https://github.com/fusesoc/fusesoc-cores sync-version = capi2 sync-type = git - auto-sync = true + auto-sync = true ? +

Check failure on line 152 in tests/test_libraries.py

View workflow job for this annotation

GitHub Actions / 🐧 ubuntu-20.04 | 3.10

test_library_add AssertionError: assert '\n[library.fusesoc-cores]\nlocation = fusesoc_libraries/fusesoc-cores\nsync-uri = https://github.com/fusesoc/fusesoc-cores\nsync-version = capi2\nsync-type = git\nauto-sync = true\n' == '[library.fusesoc-cores]\nlocation = fusesoc_libraries/fusesoc-cores\nsync-uri = https://github.com/fusesoc/fusesoc-cores\nsync-version = capi2\nsync-type = git\nauto-sync = true' + [library.fusesoc-cores] location = fusesoc_libraries/fusesoc-cores sync-uri = https://github.com/fusesoc/fusesoc-cores sync-version = capi2 sync-type = git - auto-sync = true + auto-sync = true ? +

Check failure on line 152 in tests/test_libraries.py

View workflow job for this annotation

GitHub Actions / 🐧 ubuntu-20.04 | 3.11

test_library_add AssertionError: assert '\n[library.fusesoc-cores]\nlocation = fusesoc_libraries/fusesoc-cores\nsync-uri = https://github.com/fusesoc/fusesoc-cores\nsync-version = capi2\nsync-type = git\nauto-sync = true\n' == '[library.fusesoc-cores]\nlocation = fusesoc_libraries/fusesoc-cores\nsync-uri = https://github.com/fusesoc/fusesoc-cores\nsync-version = capi2\nsync-type = git\nauto-sync = true' + [library.fusesoc-cores] location = fusesoc_libraries/fusesoc-cores sync-uri = https://github.com/fusesoc/fusesoc-cores sync-version = capi2 sync-type = git - auto-sync = true + auto-sync = true ? +

Check failure on line 152 in tests/test_libraries.py

View workflow job for this annotation

GitHub Actions / 🐧 ubuntu-20.04 | 3.12

test_library_add AssertionError: assert '\n[library.fusesoc-cores]\nlocation = fusesoc_libraries/fusesoc-cores\nsync-uri = https://github.com/fusesoc/fusesoc-cores\nsync-version = capi2\nsync-type = git\nauto-sync = true\n' == '[library.fusesoc-cores]\nlocation = fusesoc_libraries/fusesoc-cores\nsync-uri = https://github.com/fusesoc/fusesoc-cores\nsync-version = capi2\nsync-type = git\nauto-sync = true' + [library.fusesoc-cores] location = fusesoc_libraries/fusesoc-cores sync-uri = https://github.com/fusesoc/fusesoc-cores sync-version = capi2 sync-type = git - auto-sync = true + auto-sync = true ? +

Check failure on line 152 in tests/test_libraries.py

View workflow job for this annotation

GitHub Actions / 🍎 macos-latest | 3.9

test_library_add AssertionError: assert '\n[library.fusesoc-cores]\nlocation = fusesoc_libraries/fusesoc-cores\nsync-uri = https://github.com/fusesoc/fusesoc-cores\nsync-version = capi2\nsync-type = git\nauto-sync = true\n' == '[library.fusesoc-cores]\nlocation = fusesoc_libraries/fusesoc-cores\nsync-uri = https://github.com/fusesoc/fusesoc-cores\nsync-version = capi2\nsync-type = git\nauto-sync = true' + [library.fusesoc-cores] location = fusesoc_libraries/fusesoc-cores sync-uri = https://github.com/fusesoc/fusesoc-cores sync-version = capi2 sync-type = git - auto-sync = true + auto-sync = true ? +

Check failure on line 152 in tests/test_libraries.py

View workflow job for this annotation

GitHub Actions / 🍎 macos-latest | 3.10

test_library_add AssertionError: assert '\n[library.fusesoc-cores]\nlocation = fusesoc_libraries/fusesoc-cores\nsync-uri = https://github.com/fusesoc/fusesoc-cores\nsync-version = capi2\nsync-type = git\nauto-sync = true\n' == '[library.fusesoc-cores]\nlocation = fusesoc_libraries/fusesoc-cores\nsync-uri = https://github.com/fusesoc/fusesoc-cores\nsync-version = capi2\nsync-type = git\nauto-sync = true' + [library.fusesoc-cores] location = fusesoc_libraries/fusesoc-cores sync-uri = https://github.com/fusesoc/fusesoc-cores sync-version = capi2 sync-type = git - auto-sync = true + auto-sync = true ? +

Check failure on line 152 in tests/test_libraries.py

View workflow job for this annotation

GitHub Actions / 🍎 macos-latest | 3.11

test_library_add AssertionError: assert '\n[library.fusesoc-cores]\nlocation = fusesoc_libraries/fusesoc-cores\nsync-uri = https://github.com/fusesoc/fusesoc-cores\nsync-version = capi2\nsync-type = git\nauto-sync = true\n' == '[library.fusesoc-cores]\nlocation = fusesoc_libraries/fusesoc-cores\nsync-uri = https://github.com/fusesoc/fusesoc-cores\nsync-version = capi2\nsync-type = git\nauto-sync = true' + [library.fusesoc-cores] location = fusesoc_libraries/fusesoc-cores sync-uri = https://github.com/fusesoc/fusesoc-cores sync-version = capi2 sync-type = git - auto-sync = true + auto-sync = true ? +

Check failure on line 152 in tests/test_libraries.py

View workflow job for this annotation

GitHub Actions / 🍎 macos-latest | 3.12

test_library_add AssertionError: assert '\n[library.fusesoc-cores]\nlocation = fusesoc_libraries/fusesoc-cores\nsync-uri = https://github.com/fusesoc/fusesoc-cores\nsync-version = capi2\nsync-type = git\nauto-sync = true\n' == '[library.fusesoc-cores]\nlocation = fusesoc_libraries/fusesoc-cores\nsync-uri = https://github.com/fusesoc/fusesoc-cores\nsync-version = capi2\nsync-type = git\nauto-sync = true' + [library.fusesoc-cores] location = fusesoc_libraries/fusesoc-cores sync-uri = https://github.com/fusesoc/fusesoc-cores sync-version = capi2 sync-type = git - auto-sync = true + auto-sync = true ? +
shutil.rmtree("fusesoc_libraries")
tcf.close()

Expand All @@ -177,8 +176,6 @@

conf = Config(tcf.name)

args = Namespace()

Fusesoc.init_logging(False, False)
fs = Fusesoc(conf)

Expand Down Expand Up @@ -236,8 +233,6 @@

conf = Config(tcf.name)

args = Namespace()

Fusesoc.init_logging(False, False)
fs = Fusesoc(conf)

Expand Down
2 changes: 0 additions & 2 deletions tests/test_vlnv.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
# Licensed under the 2-Clause BSD License, see LICENSE for details.
# SPDX-License-Identifier: BSD-2-Clause

import pytest

from fusesoc.vlnv import Vlnv


Expand Down
Loading