Skip to content

refactor: Remove ruff ignore for "D", pydocstyle #482

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

Merged
merged 20 commits into from
Mar 5, 2025
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
1 change: 1 addition & 0 deletions doc/changelog.d/482.miscellaneous.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Remove ruff ignore for "D", pydocstyle
16 changes: 2 additions & 14 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -99,20 +99,6 @@ select = [
"TD", # flake8-todos, https://docs.astral.sh/ruff/rules/#flake8-todos-td
]
ignore = [
"D100",
"D101",
"D102",
"D103", # TODO: Add docstring to functions
"D104",
"D105",
"D200", # TODO: One-line doscstring should git on one line
"D210",
"D205", # TODO: Add one blank line between summary line and description
"D301",
"D400", # TODO: First line should end with a period
"D401",
"D404", # TODO: First word of the docstring should not be "This"
"D414",
"E402",
"E501", # TODO: Line too long
"E711",
Expand All @@ -132,6 +118,8 @@ ignore = [
"TD003", # Missing issue link in TODOs comment
]

[tool.ruff.lint.per-file-ignores]
"examples/*" = ["D100"]

[tool.ruff.lint.pydocstyle]
convention = "numpy"
Expand Down
1 change: 1 addition & 0 deletions src/ansys/speos/core/face.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ def reset(self) -> Face:

def delete(self) -> Face:
"""Delete feature: delete data from the speos server database.

The local data are still available

Returns
Expand Down
6 changes: 4 additions & 2 deletions src/ansys/speos/core/geo_ref.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,15 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

"""Provides interface to link Speos Objects to Geometries."""

from __future__ import annotations

from typing import Mapping


class GeoRef:
"""Represent a CAD object"""
"""Represent a CAD object."""

def __init__(self, name: str, description: str, metadata: Mapping[str, str]):
self.name = name
Expand All @@ -37,7 +39,7 @@ def __init__(self, name: str, description: str, metadata: Mapping[str, str]):
@staticmethod
def from_native_link(geopath: str) -> GeoRef:
"""
Convert a native link to a GeoRef
Convert a native link to a GeoRef.

Parameters
----------
Expand Down
4 changes: 4 additions & 0 deletions src/ansys/speos/core/intensity.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@

class Intensity:
"""Speos feature : Intensity.

By default, a lambertian intensity is created (cos with N=1 and total_angle=180).

Parameters
Expand Down Expand Up @@ -64,6 +65,7 @@ class Intensity:

class Library:
"""Intensity of type: Library.

By default, orientation as axis system is chosen and no exit geometries.

Parameters
Expand Down Expand Up @@ -174,6 +176,7 @@ def set_exit_geometries(

class Gaussian:
"""Intensity of type: Gaussian.

By default, full width at half maximum following x and y are set at 30 degrees, and total angle at 180 degrees.
By default, no axis system is chosen, that means normal to surface map.

Expand Down Expand Up @@ -460,6 +463,7 @@ def reset(self) -> Intensity:

def delete(self) -> Intensity:
"""Delete feature: delete data from the speos server database.

The local data are still available

Returns
Expand Down
2 changes: 1 addition & 1 deletion src/ansys/speos/core/kernel/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

"""This module manages low-level interactions and internal operations of the project."""
"""PySpeos Kernel module gathers low-level interactions and internal operations of the project."""

from ansys.speos.core.kernel.body import BodyLink, ProtoBody
from ansys.speos.core.kernel.client import SpeosClient
Expand Down
1 change: 1 addition & 0 deletions src/ansys/speos/core/kernel/crud.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

class CrudStub:
"""Wraps a speos gRPC CRUD connection.

This class is used as base class for all Speos databases interactions.
Better use directly those inherited classes like SOPTemplateStub, SpectrumStub, ...
"""
Expand Down
4 changes: 2 additions & 2 deletions src/ansys/speos/core/kernel/job.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,8 @@ def get_progress_status(self) -> messages.GetProgressStatus_Response:
)

def get_ray_paths(self) -> Iterator[RayPath]:
"""
Retrieve ray paths.
"""Retrieve ray paths.

Available for interactive simulation.

Returns
Expand Down
7 changes: 4 additions & 3 deletions src/ansys/speos/core/kernel/proto_message_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

"""Module with utility elements for protobuf messages from Speos RPC server."""

import json

from google.protobuf import __version__ as protobuf_version
Expand All @@ -29,7 +31,7 @@

def protobuf_message_to_str(message: Message, with_full_name: bool = True) -> str:
"""
Returns a protobuf message as formatted json string.
Convert a protobuf message to formatted json string.

Parameters
----------
Expand Down Expand Up @@ -67,8 +69,7 @@ def protobuf_message_to_str(message: Message, with_full_name: bool = True) -> st


def protobuf_message_to_dict(message) -> dict:
"""
Returns a protobuf message as formatted json dict.
"""Convert protobuf message to a formatted json dict.

Parameters
----------
Expand Down
4 changes: 4 additions & 0 deletions src/ansys/speos/core/launcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

"""Module to start Speos RPC Server."""

import os

from ansys.speos.core import LOG as logger
Expand All @@ -37,6 +39,7 @@

def launch_speos(version: str = None) -> Speos:
"""Start the Speos Service remotely using the product instance management API.

Prerequisite : product instance management configured.

Parameters
Expand Down Expand Up @@ -64,6 +67,7 @@ def launch_remote_speos(
version: str = None,
) -> Speos:
"""Start the Speos Service remotely using the product instance management API.

When calling this method, you need to ensure that you are in an
environment where PyPIM is configured. This can be verified with
:func:`pypim.is_configured <ansys.platform.instancemanagement.is_configured>`.
Expand Down
46 changes: 45 additions & 1 deletion src/ansys/speos/core/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ class PySpeosCustomAdapter(logging.LoggerAdapter):
stdout_handler = None

def __init__(self, logger, extra=None):
"""Initialize the logger adapter."""
self.logger = logger
if extra is not None:
self.extra = weakref.proxy(extra)
Expand All @@ -191,7 +192,21 @@ def __init__(self, logger, extra=None):
self.file_handler = logger.file_handler
self.std_out_handler = logger.std_out_handler

def process(self, msg, kwargs):
def process(self, msg, kwargs) -> tuple[str, dict]:
"""Process extra Arguments.

Parameters
----------
msg : str
Log message
kwargs : dict
extra Arguments dictionary

Returns
-------
tuple[str, dict]
Message and processed extra arguments
"""
kwargs["extra"] = {}
# This are the extra parameters sent to log
kwargs["extra"]["instance_name"] = (
Expand Down Expand Up @@ -247,11 +262,26 @@ def setLevel(self, level="DEBUG"):


class PySpeosPercentStyle(logging.PercentStyle):
"""Customized ``PercentStyle`` class for overwriting default format styles."""

def __init__(self, fmt, *, defaults=None):
"""Initialize the class."""
self._fmt = fmt or self.default_format
self._defaults = defaults

def _format(self, record):
"""Format the record.

Parameters
----------
record : logging.LogRecord
Record to format.

Returns
-------
str
Formatted record.
"""
defaults = self._defaults
if defaults:
values = defaults | record.__dict__
Expand Down Expand Up @@ -283,6 +313,7 @@ def __init__(
validate=True,
defaults=None,
):
"""Initialize the class."""
if sys.version_info[1] < 8:
super().__init__(fmt, datefmt, style)
else:
Expand All @@ -295,6 +326,18 @@ class InstanceFilter(logging.Filter):
"""Ensures that the ``instance_name`` record always exists."""

def filter(self, record):
"""Filter the record.

Parameters
----------
record : logging.LogRecord
Record to filter.

Returns
-------
bool
Whether the record is valid.
"""
if not hasattr(record, "instance_name"):
record.instance_name = ""
return True
Expand Down Expand Up @@ -530,6 +573,7 @@ def add_instance_logger(
return self._instances[new_name]

def __getitem__(self, key):
"""Magic method to allow retrieval of instances."""
if key in self._instances.keys():
return self._instances[key]
else:
Expand Down
Loading
Loading