Skip to content

fix: pyflakes style #1953

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

Draft
wants to merge 11 commits into
base: master
Choose a base branch
from
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
2 changes: 0 additions & 2 deletions .ci/code_generation.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

from ansys.dpf import core
from ansys.dpf.core.operators import build
import os
import glob
from pathlib import Path
import shutil

Expand Down
1 change: 0 additions & 1 deletion .ci/run_examples.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import os
import glob
from pathlib import Path
import subprocess
import sys
Expand Down
1 change: 0 additions & 1 deletion .ci/run_non_regression_examples.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import os
import glob
from ansys.dpf import core
import pathlib
import subprocess
Expand Down
1 change: 0 additions & 1 deletion .ci/update_dpf_dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
"""

import os
import glob
from pathlib import Path
import platform
import shutil
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ exclude: >
repos:

- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.7.3
rev: v0.8.1
hooks:
- id: ruff
args: [--fix]
Expand Down
2 changes: 2 additions & 0 deletions examples/09-averaging/00-compute_and_average.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@
def compute_von_mises_then_average(analysis):
# Create a model from the results of the simulation and retrieve its mesh
model = dpf.Model(analysis)
model.metadata.meshed_region

# Apply the stress operator to obtain the stresses in the body
stress_op = dpf.operators.result.stress()
Expand Down Expand Up @@ -135,6 +136,7 @@ def compute_von_mises_then_average(analysis):
def average_then_compute_von_mises(analysis):
# Creating the model from the results of the simulation
model = dpf.Model(analysis)
model.metadata.meshed_region

# Retrieving the stresses
stress_op = dpf.operators.result.stress()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
# Starting with DPF 2025.1.pre1
cs = dpf.operators.result.coordinate_system()
cs.inputs.data_sources.connect(model)
except (KeyError, DPFServerException) as e:
except (KeyError, DPFServerException):
# For previous DPF versions
cs = model.operator(r"mapdl::rst::CS")

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ indent-style = "space"
select = [
# "E", # pycodestyle, see https://beta.ruff.rs/docs/rules/#pycodestyle-e-w
"D", # pydocstyle, see https://beta.ruff.rs/docs/rules/#pydocstyle-d
# "F", # pyflakes, see https://beta.ruff.rs/docs/rules/#pyflakes-f
"F", # pyflakes, see https://beta.ruff.rs/docs/rules/#pyflakes-f
# "I", # isort, see https://beta.ruff.rs/docs/rules/#isort-i
# "N", # pep8-naming, see https://beta.ruff.rs/docs/rules/#pep8-naming-n
"PTH", # flake9-use-pathlib, https://beta.ruff.rs/docs/rules/#flake8-use-pathlib-pth
Expand Down
9 changes: 4 additions & 5 deletions src/ansys/dpf/core/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,10 @@
import weakref
from pathlib import Path

from ansys.dpf.core import errors, misc
from ansys.dpf.core import errors
from ansys.dpf.core import server as server_module
from ansys.dpf.core.check_version import version_requires, server_meet_version
from ansys.dpf.core.runtime_config import (
RuntimeClientConfig,
RuntimeCoreConfig,
)
from ansys.dpf.gate import (
Expand Down Expand Up @@ -538,9 +537,9 @@ def release_dpf(self):
Available with server's version starting at 6.0 (Ansys 2023R2).
"""
if self._server().has_client():
error = self._api.data_processing_release_on_client(self._server().client, 1)
self._api.data_processing_release_on_client(self._server().client, 1)
else:
error = self._api.data_processing_release(1)
self._api.data_processing_release(1)

@version_requires("4.0")
def get_runtime_core_config(self):
Expand Down Expand Up @@ -674,7 +673,7 @@ def download_file(self, server_file_path, to_client_file_path):
download service only available for server with gRPC communication protocol
"""
raise errors.ServerTypeError(txt)
client_path = self._api.data_processing_download_file(
self._api.data_processing_download_file(
client=self._server().client,
server_file_path=str(server_file_path),
to_client_file_path=str(to_client_file_path),
Expand Down
2 changes: 1 addition & 1 deletion src/ansys/dpf/core/dpf_operator.py
Original file line number Diff line number Diff line change
Expand Up @@ -1014,6 +1014,6 @@
if isinstance(output_type, types):
try:
return types_enum_to_types()[output_type]
except KeyError as e:
except KeyError:

Check warning on line 1017 in src/ansys/dpf/core/dpf_operator.py

View check run for this annotation

Codecov / codecov/patch

src/ansys/dpf/core/dpf_operator.py#L1017

Added line #L1017 was not covered by tests
raise TypeError(f"{output_type} is not an implemented Operator's output")
return output_type
99 changes: 97 additions & 2 deletions src/ansys/dpf/core/examples/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,52 @@
# SOFTWARE.
"""Provide utility functions for downloading and locating DPF example files."""

from .examples import *
from .downloads import *
from .examples import get_example_required_minimum_dpf_version, find_files, fluid_axial_model
from .downloads import (
delete_downloads,
download_transient_result,
download_all_kinds_of_complexity,
download_all_kinds_of_complexity_modal,
download_pontoon,
download_multi_harmonic_result,
download_multi_stage_cyclic_result,
download_sub_file,
download_msup_files_to_dict,
download_average_filter_plugin,
download_distributed_files,
download_fluent_multi_species,
download_fluent_multi_phase,
download_extrapolation_3d_result,
download_extrapolation_2d_result,
download_easy_statistics,
download_gltf_plugin,
download_hemisphere,
download_example_asme_result,
download_crankshaft,
download_piston_rod,
download_d3plot_beam,
download_binout_matsum,
download_binout_glstat,
download_cycles_to_failure,
download_modal_frame,
download_harmonic_clamped_pipe,
download_modal_cyclic,
download_fluent_axial_comp,
download_fluent_mixing_elbow_steady_state,
download_fluent_mixing_elbow_transient,
download_cfx_heating_coil,
download_cfx_mixing_elbow,
find_simple_bar,
find_static_rst,
find_complex_rst,
find_multishells_rst,
find_electric_therm,
find_steady_therm,
find_transient_therm,
find_msup_transient,
find_simple_cyclic,
find_distributed_msup_folder,
)


# called if module.<name> fails
Expand Down Expand Up @@ -68,3 +112,54 @@ def __getattr__(name):
distributed_msup_folder = find_distributed_msup_folder()
return distributed_msup_folder
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")


__all__ = [
"download_all_kinds_of_complexity",
"download_all_kinds_of_complexity_modal",
"get_example_required_minimum_dpf_version",
"find_files",
"fluid_axial_model",
"download_all_kinds_of_complexity",
"download_modal_frame",
"download_transient_result",
"download_multi_stage_cyclic_result",
"download_fluent_mixing_elbow_steady_state",
"download_fluent_multi_species",
"download_harmonic_clamped_pipe",
"download_binout_glstat",
"download_fluent_axial_comp",
"download_d3plot_beam",
"download_multi_harmonic_result",
"find_simple_bar",
"find_static_rst",
"find_complex_rst",
"find_multishells_rst",
"find_electric_therm",
"find_steady_therm",
"find_transient_therm",
"find_msup_transient",
"find_simple_cyclic",
"find_distributed_msup_folder",
"download_average_filter_plugin",
"delete_downloads",
"download_cfx_mixing_elbow",
"download_cfx_heating_coil",
"download_modal_cyclic",
"download_crankshaft",
"download_example_asme_result",
"download_piston_rod",
"download_fluent_mixing_elbow_transient",
"download_easy_statistics",
"download_gltf_plugin",
"download_fluent_multi_phase",
"download_pontoon",
"download_binout_matsum",
"download_cycles_to_failure",
"download_distributed_files",
"download_hemisphere",
"download_sub_file",
"download_extrapolation_3d_result",
"download_extrapolation_2d_result",
"download_msup_files_to_dict",
]
2 changes: 1 addition & 1 deletion src/ansys/dpf/core/geometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
"""Print Points information."""
txt = "DPF Points object:\n"
txt += f"Number of points: {self.n_points}\n"
txt += f"Coordinates:\n"
txt += "Coordinates:\n"

Check warning on line 95 in src/ansys/dpf/core/geometry.py

View check run for this annotation

Codecov / codecov/patch

src/ansys/dpf/core/geometry.py#L95

Added line #L95 was not covered by tests
for point in self._coordinates.data:
txt += f" {point}\n"
return txt
Expand Down
2 changes: 1 addition & 1 deletion src/ansys/dpf/core/help.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@
if oper.physics_name:
field._name = f"Sum of {field.physics_name}"
else:
field._name = f"Sum"
field._name = "Sum"

Check warning on line 126 in src/ansys/dpf/core/help.py

View check run for this annotation

Codecov / codecov/patch

src/ansys/dpf/core/help.py#L126

Added line #L126 was not covered by tests
field._unit = field._unit
return field

Expand Down
1 change: 0 additions & 1 deletion src/ansys/dpf/core/inputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,6 @@ def connect(self, inpt):
elif isinstance(inpt, Path):
inpt = str(inpt)

input_type_name = type(inpt).__name__
for input_pin in self._inputs:
self._operator()._find_outputs_corresponding_pins(
input_pin._python_expected_types,
Expand Down
1 change: 0 additions & 1 deletion src/ansys/dpf/core/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
"""Miscellaneous functions for the DPF module."""

import platform
import glob
import os
import re
from pathlib import Path
Expand Down
1 change: 0 additions & 1 deletion src/ansys/dpf/core/nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import numpy as np
from ansys.dpf.core.common import nodal_properties, locations
from ansys.dpf.core.check_version import version_requires
from ansys.dpf.core.check_version import version_requires


class Node:
Expand Down
2 changes: 0 additions & 2 deletions src/ansys/dpf/core/path_utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@
server into account to create path.
"""

import os

import ansys.dpf.core.server_types
from ansys.dpf.core import server as server_module
from pathlib import Path
Expand Down
1 change: 0 additions & 1 deletion src/ansys/dpf/core/plotter.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
from __future__ import annotations

import tempfile
import os
import sys
import numpy as np
import warnings
Expand Down
2 changes: 1 addition & 1 deletion src/ansys/dpf/core/result_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -599,7 +599,7 @@
"""
try:
return self.n_results
except Exception as e:
except Exception:

Check warning on line 602 in src/ansys/dpf/core/result_info.py

View check run for this annotation

Codecov / codecov/patch

src/ansys/dpf/core/result_info.py#L602

Added line #L602 was not covered by tests
return 0

def __iter__(self):
Expand Down
2 changes: 1 addition & 1 deletion src/ansys/dpf/core/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@

from ansys import dpf

from ansys.dpf.core.misc import is_ubuntu, get_ansys_path
from ansys.dpf.core.misc import get_ansys_path
from ansys.dpf.core import errors

from ansys.dpf.core.server_factory import (
Expand Down
9 changes: 4 additions & 5 deletions src/ansys/dpf/core/server_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
import io

from ansys.dpf.gate.load_api import (
_get_path_in_install,
_find_outdated_ansys_version,
)

Expand Down Expand Up @@ -317,7 +316,7 @@
"""
text = f"Server configuration: protocol={self.protocol}"
if self.legacy:
text += f" (legacy gRPC)"
text += " (legacy gRPC)"

Check warning on line 319 in src/ansys/dpf/core/server_factory.py

View check run for this annotation

Codecov / codecov/patch

src/ansys/dpf/core/server_factory.py#L319

Added line #L319 was not covered by tests
return text

def __eq__(self, other: "ServerConfig"):
Expand Down Expand Up @@ -398,9 +397,9 @@
config = AvailableServerConfigs.LegacyGrpcServer
else:
raise NotImplementedError(
f"DPF_SERVER_TYPE environment variable must "
f"be set to one of the following: INPROCESS, "
f"GRPC, LEGACYGRPC."
"DPF_SERVER_TYPE environment variable must "
"be set to one of the following: INPROCESS, "
"GRPC, LEGACYGRPC."
)
elif config is None and docker_config.use_docker:
config = get_default_remote_server_config()
Expand Down
2 changes: 1 addition & 1 deletion src/ansys/dpf/core/server_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
ANSYS_INSTALL = Path(core.misc.get_ansys_path(ansys_path))
api_path = load_api._get_path_in_install()
if api_path is None:
raise ImportError(f"Could not find API path in install.")
raise ImportError("Could not find API path in install.")

Check warning on line 75 in src/ansys/dpf/core/server_types.py

View check run for this annotation

Codecov / codecov/patch

src/ansys/dpf/core/server_types.py#L75

Added line #L75 was not covered by tests
SUB_FOLDERS = ANSYS_INSTALL / api_path
if ISPOSIX:
name = "lib" + name
Expand Down
2 changes: 1 addition & 1 deletion src/ansys/dpf/core/unit_system.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,5 +152,5 @@ class unit_systems:
solver_bft = UnitSystem("solver_bft", ID=7)
solver_bin = UnitSystem("solver_bin", ID=8)
undefined = UnitSystem("undefined", ID=-1)
except dpf_errors.DpfVersionNotSupported as e: # pragma: no cover
except dpf_errors.DpfVersionNotSupported: # pragma: no cover
pass
2 changes: 2 additions & 0 deletions src/ansys/dpf/core/workflow_topology/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,5 @@
from .operator_connection import OperatorConnection
from .data_connection import DataConnection
from .exposed_pin import ExposedPin

__all__ = [WorkflowTopology, OperatorConnection, DataConnection, ExposedPin]
1 change: 0 additions & 1 deletion tests/test_animation.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

import os
from pathlib import Path

import pytest
Expand Down
1 change: 0 additions & 1 deletion tests/test_animator.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

import os
from pathlib import Path

import pytest
Expand Down
1 change: 0 additions & 1 deletion tests/test_codegeneration.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
# SOFTWARE.

# -*- coding: utf-8 -*-
import os
import copy
import tempfile
from pathlib import Path
Expand Down
Loading
Loading