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

Bump pre-commit/action from 3.0.0 to 3.0.1 #190

Merged
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
2 changes: 1 addition & 1 deletion .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ jobs:
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- uses: pre-commit/action@v3.0.0
- uses: pre-commit/action@v3.0.1
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ repos:
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/python-poetry/poetry
rev: 1.7.0
rev: 1.8.0
hooks:
- id: poetry-check
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.2.1
rev: v0.3.0
hooks:
- id: ruff
types_or: [python, pyi, jupyter]
Expand Down
489 changes: 242 additions & 247 deletions poetry.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ networkx = ">=3.0.0"

[tool.poetry.group.dev.dependencies]
pre-commit = "^3.0.0"
ruff = ">=0.2.0"
ruff = ">=0.3.0"

[tool.poetry.group.doc.dependencies]
sphinx = "^7.0.1"
Expand Down
1 change: 1 addition & 0 deletions roseau/load_flow/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

See Package Contents below for a list of available classes and functions.
"""

import importlib.metadata

from roseau.load_flow.__about__ import (
Expand Down
47 changes: 28 additions & 19 deletions roseau/load_flow/conftest.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import importlib
import inspect
import os
from pathlib import Path

import numpy as np
import pytest
import setuptools
from _pytest.monkeypatch import MonkeyPatch
from pandas.testing import assert_frame_equal

Expand Down Expand Up @@ -52,26 +52,35 @@ def __getattr__(self, attr): # Accept all methods
def foo(self, *args, **kwargs):
pass

def bar(*args, **kwargs):
pass

# Get all roseau.load_flow submodules
package_names = [
f"{roseau.load_flow.__name__}.{x}" for x in setuptools.find_packages(os.path.dirname(roseau.load_flow.__file__))
]
modules = [roseau.load_flow]
final_modules = []
while modules:
module = modules.pop(-1)
new_modules = [m[1] for m in inspect.getmembers(module, predicate=inspect.ismodule)]
final_modules.extend(new_modules)
for m in new_modules:
if m.__name__ in package_names:
modules.append(m)
# Patch all cython classes
mpatch = MonkeyPatch()
for module in final_modules:
classes = inspect.getmembers(module, predicate=inspect.isclass)
for class_name, _class in classes:
if class_name.startswith("Cy"):
mpatch.setattr(f"{module.__name__}.{_class.__name__}", Foo)
rlf_directory_path = Path(roseau.load_flow.__file__).parent
rlf_engine_prefix = "roseau.load_flow_engine."
relative_to = Path(roseau.load_flow.__file__).parents[2]
for dirpath, _, filenames in os.walk(rlf_directory_path): # TODO In Python 3.12 use rlf_directory_path.walk()
dirpath = Path(dirpath) # TODO Useless in Python 3.12
for p in dirpath.parts:
if p in {"tests", "__pycache__", "data"}:
break
else:
base_module = str(dirpath.relative_to(relative_to)).replace("/", ".")
for f in filenames:
if not f.endswith(".py"):
continue
module = importlib.import_module(f"{base_module}.{f.removesuffix('.py')}")
for _, klass in inspect.getmembers(
module,
lambda member: inspect.isclass(member)
and member.__module__.startswith(rlf_engine_prefix)
and member.__name__.startswith("Cy"),
):
mpatch.setattr(f"{module.__name__}.{klass.__name__}", Foo)

# Also patch the activate license function of the _solvers module
mpatch.setattr("roseau.load_flow._solvers.activate_license", bar)
yield mpatch
mpatch.undo()

Expand Down
1 change: 1 addition & 0 deletions roseau/load_flow/converters.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* convert between phasor and symmetrical components
* convert potentials to voltages
"""

from collections.abc import Sequence

import numpy as np
Expand Down
1 change: 1 addition & 0 deletions roseau/load_flow/exceptions.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
This module contains the exceptions used by Roseau Load Flow.
"""

from enum import auto

from roseau.load_flow._compat import StrEnum
Expand Down
1 change: 1 addition & 0 deletions roseau/load_flow/io/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
You do not need to use this module directly, you can read and write networks using the
corresponding methods of the :class:`~roseau.load_flow.ElectricalNetwork` object.
"""

from roseau.load_flow.io.dgs import network_from_dgs
from roseau.load_flow.io.dict import network_from_dict, network_to_dict

Expand Down
1 change: 1 addition & 0 deletions roseau/load_flow/io/dgs.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

Use the `ElectricalNetwork.from_dgs` method to read a network from a dgs file.
"""

import json
import logging

Expand Down
1 change: 1 addition & 0 deletions roseau/load_flow/io/dict.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from and to dictionaries, or the methods `ElectricalNetwork.from_json` and `ElectricalNetwork.to_json`
to read and write networks from and to JSON files.
"""

import copy
import logging
from typing import TYPE_CHECKING
Expand Down
1 change: 1 addition & 0 deletions roseau/load_flow/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

Equations, diagrams, and examples can be found in the :doc:`/models/index` page.
"""

from roseau.load_flow.models.branches import AbstractBranch
from roseau.load_flow.models.buses import Bus
from roseau.load_flow.models.core import Element
Expand Down
1 change: 1 addition & 0 deletions roseau/load_flow/network.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
This module defines the electrical network class.
"""

import json
import logging
import re
Expand Down
1 change: 1 addition & 0 deletions roseau/load_flow/typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
A 2D array-like of complex numbers or a quantity of complex numbers. An array-like is a
sequence or a numpy array.
"""

import os
from collections.abc import Mapping, Sequence
from typing import Any, Literal, TypeAlias, TypeVar
Expand Down
1 change: 1 addition & 0 deletions roseau/load_flow/units.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

.. _pint: https://pint.readthedocs.io/en/stable/getting/overview.html
"""

from collections.abc import Callable, Iterable
from types import GenericAlias
from typing import TYPE_CHECKING, TypeAlias, TypeVar
Expand Down
1 change: 1 addition & 0 deletions roseau/load_flow/utils/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
This module contains utility classes and functions for Roseau Load Flow.
"""

from roseau.load_flow.utils.constants import DELTA_P, EPSILON_0, EPSILON_R, MU_0, MU_R, OMEGA, PI, RHO, TAN_D, F
from roseau.load_flow.utils.mixins import CatalogueMixin, Identifiable, JsonMixin
from roseau.load_flow.utils.types import (
Expand Down
6 changes: 2 additions & 4 deletions roseau/load_flow/utils/mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,13 +251,11 @@ def from_catalogue(cls, **kwargs) -> Self:

@overload
@staticmethod
def _filter_catalogue_str(value: str | re.Pattern[str], strings: pd.Series) -> "pd.Series[bool]":
...
def _filter_catalogue_str(value: str | re.Pattern[str], strings: pd.Series) -> "pd.Series[bool]": ...

@overload
@staticmethod
def _filter_catalogue_str(value: str | re.Pattern[str], strings: list[str]) -> list[str]:
...
def _filter_catalogue_str(value: str | re.Pattern[str], strings: list[str]) -> list[str]: ...

@staticmethod
def _filter_catalogue_str(
Expand Down
1 change: 1 addition & 0 deletions scripts/generate_network_catalogue_data.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""Generate the catalogue data of the networks folder. This json file contains some statistics on the available
networks."""

import json
from pathlib import Path

Expand Down
1 change: 1 addition & 0 deletions scripts/generate_transformer_parameters_catalogue.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Generate the catalogue of transformers from the CSV file of transformers."""

from pathlib import Path

import numpy as np
Expand Down
1 change: 1 addition & 0 deletions scripts/update_catalogue_networks.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

See https://github.com/RoseauTechnologies/Roseau_Load_Flow/issues/181
"""

import re

import numpy as np
Expand Down
Loading