diff --git a/pyproject.toml b/pyproject.toml index 9a0ef132..92efc1d1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -112,14 +112,12 @@ extend-include = ["*.ipynb"] [tool.ruff.lint] select = ["ALL"] ignore = [ - "FBT", # flake8-boolean-trap - "TRY", # ignore tryceratops. - # Others. - "ANN101", # type annotating self - "ANN102", # type annotating cls + "ANN101", + "ANN102", "ANN401", # flake8-annotate typing.Any "COM812", # Comply with ruff-format. "ISC001", # Comply with ruff-format. + "FBT", "PD901", # Avoid generic df for dataframes. "S101", # raise errors for asserts. "S603", # Call check with subprocess.run. diff --git a/src/_pytask/_inspect.py b/src/_pytask/_inspect.py index a6a5a730..f251c6b9 100644 --- a/src/_pytask/_inspect.py +++ b/src/_pytask/_inspect.py @@ -106,7 +106,7 @@ def get_annotations( # noqa: C901, PLR0912, PLR0915 if not isinstance(ann, dict): msg = f"{obj!r}.__annotations__ is neither a dict nor None" - raise ValueError(msg) + raise ValueError(msg) # noqa: TRY004 if not ann: return {} diff --git a/src/_pytask/dag_command.py b/src/_pytask/dag_command.py index 9b7bdecb..f5f7accb 100644 --- a/src/_pytask/dag_command.py +++ b/src/_pytask/dag_command.py @@ -188,24 +188,17 @@ def build_dag(raw_config: dict[str, Any]) -> nx.DiGraph: session = Session(exit_code=ExitCode.CONFIGURATION_FAILED) else: - try: - session.hook.pytask_log_session_header(session=session) - import_optional_dependency("pygraphviz") - check_for_optional_program( - session.config["layout"], - extra="The layout program is part of the graphviz package that you " - "can install with conda.", - ) - session.hook.pytask_collect(session=session) - session.dag = create_dag(session=session) - session.hook.pytask_unconfigure(session=session) - dag = _refine_dag(session) - - except Exception: - raise - - else: - return dag + session.hook.pytask_log_session_header(session=session) + import_optional_dependency("pygraphviz") + check_for_optional_program( + session.config["layout"], + extra="The layout program is part of the graphviz package that you " + "can install with conda.", + ) + session.hook.pytask_collect(session=session) + session.dag = create_dag(session=session) + session.hook.pytask_unconfigure(session=session) + return _refine_dag(session) def _refine_dag(session: Session) -> nx.DiGraph: diff --git a/src/_pytask/path.py b/src/_pytask/path.py index 05027092..d0bf1f58 100644 --- a/src/_pytask/path.py +++ b/src/_pytask/path.py @@ -25,7 +25,7 @@ ] -def relative_to(path: Path, source: Path, include_source: bool = True) -> Path: +def relative_to(path: Path, source: Path, *, include_source: bool = True) -> Path: """Make a path relative to another path. In contrast to :meth:`pathlib.Path.relative_to`, this function allows to keep the @@ -191,7 +191,7 @@ def _insert_missing_modules(modules: dict[str, ModuleType], module_name: str) -> # sys.meta_path explicitly and raise the error ourselves to fall back to # creating a dummy module. if not sys.meta_path: - raise ModuleNotFoundError + raise ModuleNotFoundError # noqa: TRY301 importlib.import_module(module_name) except ModuleNotFoundError: module = ModuleType( diff --git a/src/_pytask/warnings_utils.py b/src/_pytask/warnings_utils.py index c4502510..61c6597b 100644 --- a/src/_pytask/warnings_utils.py +++ b/src/_pytask/warnings_utils.py @@ -95,7 +95,7 @@ def parse_warning_filter( # noqa: PLR0912, C901 lineno = int(lineno_) if lineno < 0: msg = "number is negative" - raise ValueError(msg) + raise ValueError(msg) # noqa: TRY301 except ValueError as e: raise Exit( # noqa: B904 error_template.format(error=f"invalid lineno {lineno_!r}: {e}") diff --git a/tests/test_path.py b/tests/test_path.py index e7df4389..d79f4ffa 100644 --- a/tests/test_path.py +++ b/tests/test_path.py @@ -28,7 +28,7 @@ ], ) def test_relative_to(path, source, include_source, expected): - result = relative_to(path, source, include_source) + result = relative_to(path, source, include_source=include_source) assert result == expected