Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
1a41115
docs(examples): escape backslash in Young's modulus math expression i…
germa89 Nov 17, 2025
9f9f7aa
refactor(commands): introduce CommandsBase with typed run() and make …
germa89 Nov 17, 2025
c7d256a
typing: use TypeAlias for Literal-based type aliases and add type ann…
germa89 Nov 17, 2025
d2fef94
typing: refine type annotations, add type ignores, and fix minor issues
germa89 Nov 17, 2025
931bc32
typing: refine type annotations and improve runtime robustness across…
germa89 Nov 17, 2025
7254066
fix(core): improve robustness for regex matches, None handling, and p…
germa89 Nov 18, 2025
2fe97ff
typing: refine annotations and add type ignores across core modules
germa89 Nov 18, 2025
5bc4155
mypy: add exclude paths and enable namespace/explicit package bases i…
germa89 Nov 18, 2025
746d3e8
chore: merge remote-tracking branch 'origin/main' into fix/mypy-errors
germa89 Nov 18, 2025
f1907de
typing: refine annotations and fix mypy issues across core modules
germa89 Nov 18, 2025
2317d1c
Fix licensing.py type annotation for licenses list assignment
germa89 Nov 18, 2025
8c7e112
Fix mapdl_grpc.py type issues: None checks, type annotations, timeout…
germa89 Nov 18, 2025
d85ee0f
Fix common_grpc.py: replace None with empty string in list items
germa89 Nov 18, 2025
f785249
Fix database.py: add None check for environment variable
germa89 Nov 18, 2025
6100d61
Fix mapdl_core.py: initialize _remove_tmp as bool instead of None
germa89 Nov 18, 2025
7697ac1
Fix pool.py: handle Optional timeout parameter
germa89 Nov 18, 2025
72ebf9a
Fix mesh_grpc.py: cast float to int for list assignment
germa89 Nov 18, 2025
93fe786
Fix verif_files.py: add None check for inspect.currentframe()
germa89 Nov 18, 2025
d44cb5d
Fix commands.py: add value parameter to property setter
germa89 Nov 18, 2025
4e66977
Fix helpers.py: remove unused namedtuple import
germa89 Nov 18, 2025
e015e53
Fix parameters.py: move type ignore to individual dict entries
germa89 Nov 18, 2025
587f2f2
Fix krylov.py: add type ignore for operator issues with dynamic types
germa89 Nov 18, 2025
085026b
Fix .ci/pytest_summary.py: add index type ignore comments
germa89 Nov 18, 2025
a84260e
Add doc/ and examples/ exclusions to mypy pre-commit hook
germa89 Nov 18, 2025
e2ea13d
chore: adding changelog file 4309.fixed.md [dependabot-skip]
pyansys-ci-bot Nov 18, 2025
1cc8e2f
Delete .codacy/codacy.yaml
germa89 Nov 18, 2025
402d577
fix (common_grpc.py): relax parse_chunks typing to Any, add numpy.typ…
germa89 Nov 18, 2025
0ccd148
Merge branch 'fix/mypy-errors' of https://github.com/ansys/pymapdl in…
germa89 Nov 18, 2025
8e5c9a0
fix (mapdl_core.py, mesh_grpc.py, tests/test_commands.py): return plo…
germa89 Nov 21, 2025
6e1f7c0
ci (.pre-commit-config.yaml): remove skip for mypy hook
germa89 Nov 21, 2025
ec72b1f
refactor (misc.py): simplify creation_time by using hasattr(stat, "st…
germa89 Nov 21, 2025
f0114e4
fix (misc.py): add type: ignore for stat.st_birthtime in creation_time
germa89 Nov 21, 2025
a95eae0
fix (parameters.py): initialize name_ in interp_star_status to avoid …
germa89 Nov 21, 2025
969593d
ci (.github/workflows/migrator.yml): add zizmor ignore comment to per…
germa89 Nov 21, 2025
3e94c81
Merge branch 'main' into fix/mypy-errors
germa89 Nov 26, 2025
7b6f96b
Merge branch 'main' into fix/mypy-errors
germa89 Nov 26, 2025
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
16 changes: 8 additions & 8 deletions .ci/pytest_summary.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,15 +79,15 @@ def compute_statistics(
test_stats: dict[str, TEST_STATS_TYPE] = {}

for test in tests:
test_id: str = test["id"]
test_id = test["id"] # type: ignore[assignment]
if test_id not in test_stats:
test_stats[test_id] = {
test_stats[test_id] = { # type: ignore[index]
"durations": [],
"n_tests": 0,
}

test_stats[test_id]["durations"].append(test["duration"])
test_stats[test_id]["n_tests"] += 1
test_stats[test_id]["durations"].append(test["duration"]) # type: ignore[arg-type,index]
test_stats[test_id]["n_tests"] += 1 # type: ignore[index]

summary: list[dict[str, Any]] = []

Expand Down Expand Up @@ -170,10 +170,10 @@ def make_bold(s: str) -> str:
for i, each_key in enumerate(keys):

if i == 0:
id_: str = test[each_key]
id_ = test[each_key] # type: ignore[assignment]

id_ = (
id_.replace("(", r"(")
id_.replace("(", r"(") # type: ignore[union-attr]
.replace(")", r")")
.replace("[", r"[")
.replace("]", r"]")
Expand All @@ -197,8 +197,8 @@ def make_bold(s: str) -> str:

def print_summary(summary: list[dict[str, str | float]], num: int = 10):
"""Print the top N longest tests and the top N most variable tests."""
longest_tests = sorted(summary, key=lambda x: -x["average_duration"])[:num]
most_variable_tests = sorted(summary, key=lambda x: -x["std_dev"])[:num]
longest_tests = sorted(summary, key=lambda x: -x["average_duration"])[:num] # type: ignore[operator]
most_variable_tests = sorted(summary, key=lambda x: -x["std_dev"])[:num] # type: ignore[operator]

print(f"\n## Top {num} Longest Running Tests\n")
print_table(
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/migrator.yml
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ jobs:
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 #v5.0.0
with:
ref: main
persist-credentials: true
persist-credentials: true # zizmor: ignore[artipacked]

- name: Clone head repo and checkout branch. Resolve conflicts if needed.
if : ${{ env.CONTINUE == 'true' }}
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ ci:

# PR name when autoupdate
autoupdate_commit_msg: 'ci: pre-commit autoupdate'
skip: [mypy]


repos:
Expand All @@ -24,6 +23,7 @@ repos:
hooks:
- id: mypy
args: [ --follow-imports=silent, --config-file=pyproject.toml]
exclude: ^(doc/|examples/)

- repo: https://github.com/ansys/pre-commit-hooks
rev: v0.5.2
Expand Down
1 change: 1 addition & 0 deletions doc/changelog.d/4309.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Mypy type checking issues across core modules
2 changes: 1 addition & 1 deletion examples/00-mapdl-examples/bracket_static.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
~~~~~~~~~~~~~

The dimensions of the corner bracket are shown in the following figure.
The bracket is made of A36 steel with a Young's modulus of :math:`3\cdot 10^7` psi
The bracket is made of A36 steel with a Young's modulus of :math:`3\\cdot 10^7` psi
and Poisson's ratio of :math:`0.27`.

.. figure:: ../../../images/bracket_dimensions.png
Expand Down
12 changes: 12 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,18 @@ disable_error_code = [
"return",
"return-value",
]
exclude = [
"^\\.ci/",
"^build/",
"^dist/",
"^doc/",
"^examples/",
"^htmlcov/",
"^tests/",
]
explicit_package_bases = true
namespace_packages = true


[tool.towncrier]
directory = "doc/changelog.d"
Expand Down
43 changes: 43 additions & 0 deletions src/ansys/mapdl/core/_commands/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,46 @@
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

from typing import Any, Optional


class CommandsBase:
"""Base class for MAPDL command mixin classes.

This class declares the interface that command mixin classes rely on.
The actual implementation of the run method is provided by the parent
MAPDL class when these command mixins are combined via multiple inheritance.
"""

def run(
self,
command: str,
write_to_log: bool = True,
mute: Optional[bool] = None,
**kwargs: Any,
) -> str:
"""Run a single APDL command.

This method is implemented by the parent MAPDL class.
Command mixins can call this method to execute APDL commands.

Parameters
----------
command : str
ANSYS APDL command.
write_to_log : bool, optional
Whether to write command to log. Default ``True``.
mute : bool, optional
Whether to mute command output.
**kwargs : Any
Additional keyword arguments.

Returns
-------
str
Command output from MAPDL.
"""
raise NotImplementedError(
"The run method must be provided by the parent MAPDL class"
)
4 changes: 3 additions & 1 deletion src/ansys/mapdl/core/_commands/apdl/abbreviations.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

from ansys.mapdl.core._commands import CommandsBase

class Abbreviations:

class Abbreviations(CommandsBase):

def abbr(self, abbr: str = "", string: str = "", **kwargs):
r"""Defines an abbreviation.
Expand Down
4 changes: 3 additions & 1 deletion src/ansys/mapdl/core/_commands/apdl/array_parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

from ansys.mapdl.core._commands import CommandsBase

class ArrayParameters:

class ArrayParameters(CommandsBase):

def mfouri(
self,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

from ansys.mapdl.core._commands import CommandsBase

class EncryptionDecryption:

class EncryptionDecryption(CommandsBase):

def dbdecrypt(
self,
Expand Down
4 changes: 3 additions & 1 deletion src/ansys/mapdl/core/_commands/apdl/macro_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

from ansys.mapdl.core._commands import CommandsBase

class MacroFiles:

class MacroFiles(CommandsBase):

def cfclos(self, **kwargs):
r"""Closes the "command" file.
Expand Down
4 changes: 3 additions & 1 deletion src/ansys/mapdl/core/_commands/apdl/matrix_operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

from ansys.mapdl.core._commands import CommandsBase

class MatrixOperations:

class MatrixOperations(CommandsBase):

def axpy(
self,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

from ansys.mapdl.core._commands import CommandsBase

class ParameterDefinition:

class ParameterDefinition(CommandsBase):

def afun(self, lab: str = "", **kwargs):
r"""Specifies units for angular functions in parameter expressions.
Expand Down
4 changes: 3 additions & 1 deletion src/ansys/mapdl/core/_commands/apdl/process_controls.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

from ansys.mapdl.core._commands import CommandsBase

class ProcessControls:

class ProcessControls(CommandsBase):

def starexit(self, **kwargs):
r"""Exits a do-loop.
Expand Down
4 changes: 3 additions & 1 deletion src/ansys/mapdl/core/_commands/aux12/general_radiation.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

from ansys.mapdl.core._commands import CommandsBase

class GeneralRadiation:

class GeneralRadiation(CommandsBase):

def aux12(self, **kwargs):
r"""Enters the radiation processor.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

from ansys.mapdl.core._commands import CommandsBase

class RadiationMatrixMethod:

class RadiationMatrixMethod(CommandsBase):

def emis(self, mat: str = "", evalu: str = "", **kwargs):
r"""Specifies emissivity as a material property for the Radiation Matrix method.
Expand Down
4 changes: 3 additions & 1 deletion src/ansys/mapdl/core/_commands/aux12/radiosity_solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

from ansys.mapdl.core._commands import CommandsBase

class RadiositySolver:

class RadiositySolver(CommandsBase):

def vfco(self, action: str = "", encl: str = "", level: int | str = "", **kwargs):
r"""Controls the use and level of view factor condensation for symmetric radiation.
Expand Down
4 changes: 3 additions & 1 deletion src/ansys/mapdl/core/_commands/aux15/iges.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

from ansys.mapdl.core._commands import CommandsBase

class Iges:

class Iges(CommandsBase):

def aux15(self, **kwargs):
r"""Enters the IGES file transfer processor.
Expand Down
4 changes: 3 additions & 1 deletion src/ansys/mapdl/core/_commands/aux2/binary_file_dump.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

from ansys.mapdl.core._commands import CommandsBase

class BinaryFileDump:

class BinaryFileDump(CommandsBase):

def aux2(self, **kwargs):
r"""Enters the binary file dumping processor.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

from ansys.mapdl.core._commands import CommandsBase

class BinaryFileManipulation:

class BinaryFileManipulation(CommandsBase):

def combine(self, filetype: str = "", num: str = "", **kwargs):
r"""Combines distributed memory parallel ( DMP ) files.
Expand Down
4 changes: 3 additions & 1 deletion src/ansys/mapdl/core/_commands/aux3/results_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

from ansys.mapdl.core._commands import CommandsBase

class ResultsFiles:

class ResultsFiles(CommandsBase):

def aux3(self, **kwargs):
r"""Enters the results file editing processor.
Expand Down
4 changes: 3 additions & 1 deletion src/ansys/mapdl/core/_commands/conn.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

from ansys.mapdl.core._commands import CommandsBase

class Conn:

class Conn(CommandsBase):
def cat5in(
self,
name="",
Expand Down
4 changes: 3 additions & 1 deletion src/ansys/mapdl/core/_commands/database/components.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

from ansys.mapdl.core._commands import CommandsBase

class Components:

class Components(CommandsBase):

def cm(self, cname: str = "", entity: str = "", kopt: str = "", **kwargs):
r"""Groups geometry items into a component.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

from ansys.mapdl.core._commands import CommandsBase

class CoordinateSystem:

class CoordinateSystem(CommandsBase):

def clocal(
self,
Expand Down
4 changes: 3 additions & 1 deletion src/ansys/mapdl/core/_commands/database/picking.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

from ansys.mapdl.core._commands import CommandsBase

class Picking:

class Picking(CommandsBase):

def fitem(
self,
Expand Down
4 changes: 3 additions & 1 deletion src/ansys/mapdl/core/_commands/database/selecting.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

from ansys.mapdl.core._commands import CommandsBase

class Selecting:

class Selecting(CommandsBase):

def allsel(self, labt: str = "", entity: str = "", **kwargs):
r"""Selects all entities with a single command.
Expand Down
4 changes: 3 additions & 1 deletion src/ansys/mapdl/core/_commands/database/set_up.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

from ansys.mapdl.core._commands import CommandsBase

class SetUp:

class SetUp(CommandsBase):

def clear(self, read: str = "", **kwargs):
r"""Clears the database.
Expand Down
4 changes: 3 additions & 1 deletion src/ansys/mapdl/core/_commands/database/working_plane.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

from ansys.mapdl.core._commands import CommandsBase

class WorkingPlane:

class WorkingPlane(CommandsBase):

def kwpave(
self,
Expand Down
Loading
Loading