Commit bf6115e
fix: mypy type checking issues across core modules (#4309)
* docs(examples): escape backslash in Young's modulus math expression in bracket_static example
* refactor(commands): introduce CommandsBase with typed run() and make command mixins inherit
Add a CommandsBase class (with a typed run(command, write_to_log, mute, **kwargs) stub)
to declare the interface used by APDL command mixins. Update numerous command modules
to import and inherit from CommandsBase so mixins consistently express the expected
run() contract for the parent MAPDL class.
* typing: use TypeAlias for Literal-based type aliases and add type annotations
Convert several Literal tuple usages to explicit TypeAlias (ENTITIES_TYP,
RESIDUAL_ALGORITHM_LITERAL, VALID_DEVICES_LITERAL, VALID_FILE_TYPE_FOR_PLOT_LITERAL),
import TypeAlias where needed, and add typing annotations for base_report_class.
Minor typing cleanup and ignore-type for Report subclassing.
* typing: refine type annotations, add type ignores, and fix minor issues
- common_grpc: annotate parse_chunks as grpc.CallIterator (ignore name-defined)
- component: correct ENTITIES_MAPPING typing, tighten Component __new__/repr/type signatures and add attr type ignores
- helpers: fix namedtuple import from collections
- krylov: guard residuals with None check and add attr type ignore on append
- logging: add type ignores for dynamic logger handler attributes
- mapdl_core: fix mesh check (grid.n_node), accept pathlib.Path in _decompose_fname, add asserts for newly created/opened resources, and local rename for clarity
- mapdl_geometry: allow ndarray for _select_items parameter
- misc: broaden routine parameters to accept str or ROUTINES and add type ignores for mapdl attribute access
- pool: avoid shadowing timeout by renaming and add type ignore for progress bar update
These changes improve typing correctness, silence false-positive type errors, and address several small bugs/clarifications.
* typing: refine type annotations and improve runtime robustness across core modules
- component: broaden Component.__new__ to accept lists, ndarrays, ints, strs, Components and None; coerce items to tuple and handle fallbacks. Make ComponentManager handle cmtype as string or [selection, type] and guard cmlist parsing for None.
- krylov: tighten typing (Optional[str] for full_file), accept int/str for frequency inputs, allow residual_algorithm to be Optional and validate only when provided.
- licensing: raise OSError when home directory cannot be determined before building license path.
- mapdl_core: accept pathlib.Path or str in _wrap_directory.
- mapdl_extended / mapdl_grpc: add targeted type ignores and refine parameter types (chunk_size, progress_bar, _mapdl_process, vget/nvar, VAR_IR) to satisfy static typing and avoid mypy issues.
- misc: robust MODULE_PATH resolution using inspect.currentframe() with fallback to __file__.
* fix(core): improve robustness for regex matches, None handling, and parent/type guards
- component: refine __getitem__ return annotation to Component (type: ignore[override])
- krylov: guard residual_algorithm against None before calling .lower()
- licensing: handle missing subprocess.stdout, ensure licenses is a list, and check output type before searching for error messages
- logging: check self.extra is not None before accessing .name
- mapdl_core: cache parent reference in WithInterativePlotting and assert it's not None; avoid repeated _parent() calls
- mapdl_extended: safely search for the table block before parsing and only populate the table if a match is found
- mapdl_grpc: return empty string instead of None from command response helper
- mesh_grpc: use safe regex matches when extracting REAL CONSTANT SET, ITEMS, and TO values
- parameters: guard regex searches when extracting parameter names and string elements to avoid AttributeError
* typing: refine annotations and add type ignores across core modules
- fix Literal alias declaration in common_grpc
- tighten Optional/Union signatures and use TypeAlias where appropriate
- add explicit variable typings and where necessary
- small parsing/type improvements in component, parameters, misc
- annotate/adjust dynamic fields in mapdl_core, mapdl_grpc, licensing, pool, krylov, logging
Improve type clarity and runtime robustness while keeping dynamic assignments compatible with runtime values.
* mypy: add exclude paths and enable namespace/explicit package bases in pyproject.toml
* typing: refine annotations and fix mypy issues across core modules
Add/adjust type hints (TextIO, Optional, list[str], TYPE_CHECKING imports), tighten function signatures, add targeted type:ignore comments, cast query results to int for SelectionStatus, and improve internal type checks/assertions. Also rename a few tests for clearer descriptions.
* Fix licensing.py type annotation for licenses list assignment
* Fix mapdl_grpc.py type issues: None checks, type annotations, timeout handling
* Fix common_grpc.py: replace None with empty string in list items
* Fix database.py: add None check for environment variable
* Fix mapdl_core.py: initialize _remove_tmp as bool instead of None
* Fix pool.py: handle Optional timeout parameter
* Fix mesh_grpc.py: cast float to int for list assignment
* Fix verif_files.py: add None check for inspect.currentframe()
* Fix commands.py: add value parameter to property setter
* Fix helpers.py: remove unused namedtuple import
* Fix parameters.py: move type ignore to individual dict entries
* Fix krylov.py: add type ignore for operator issues with dynamic types
* Fix .ci/pytest_summary.py: add index type ignore comments
* Add doc/ and examples/ exclusions to mypy pre-commit hook
* chore: adding changelog file 4309.fixed.md [dependabot-skip]
* Delete .codacy/codacy.yaml
* fix (common_grpc.py): relax parse_chunks typing to Any, add numpy.typing import, and update docstring
* fix (mapdl_core.py, mesh_grpc.py, tests/test_commands.py): return plot filename from screenshot, refine rlist typing, update test commands
- mapdl_core.py: change _download_plot to return the copied filename (str); update screenshot signature/return to str | None and adjust logic/docstring so providing savefig returns the saved filename.
- mesh_grpc.py: tighten _parse_rlist typing to dict[int, list[int | float]] and fix parsing/assignment so real-constant values preserve numeric types.
- tests/test_commands.py: include "run" in the tested command list.
* ci (.pre-commit-config.yaml): remove skip for mypy hook
* refactor (misc.py): simplify creation_time by using hasattr(stat, "st_birthtime") and return mtime fallback
* fix (misc.py): add type: ignore for stat.st_birthtime in creation_time
* fix (parameters.py): initialize name_ in interp_star_status to avoid unbound local reference
* ci (.github/workflows/migrator.yml): add zizmor ignore comment to persist-credentials setting
* fix(action): correct shell command for starting Julia in test action
* fix: bandit check
* fix: asserts
---------
Co-authored-by: pyansys-ci-bot <[email protected]>
Co-authored-by: clatapie <[email protected]>1 parent 8a2ed11 commit bf6115e
File tree
151 files changed
+814
-388
lines changed- .ci
- .github
- actions/test-julia
- workflows
- doc/changelog.d
- examples/00-mapdl-examples
- src/ansys/mapdl/core
- _commands
- apdl
- aux12
- aux15
- aux2
- aux3
- database
- graphics
- map
- misc
- post1
- post26
- preproc
- session
- solution
- cli
- database
- examples
- inline_functions
- plotting
- tests
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
151 files changed
+814
-388
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
79 | 79 | | |
80 | 80 | | |
81 | 81 | | |
82 | | - | |
| 82 | + | |
83 | 83 | | |
84 | | - | |
| 84 | + | |
85 | 85 | | |
86 | 86 | | |
87 | 87 | | |
88 | 88 | | |
89 | | - | |
90 | | - | |
| 89 | + | |
| 90 | + | |
91 | 91 | | |
92 | 92 | | |
93 | 93 | | |
| |||
170 | 170 | | |
171 | 171 | | |
172 | 172 | | |
173 | | - | |
| 173 | + | |
174 | 174 | | |
175 | 175 | | |
176 | | - | |
| 176 | + | |
177 | 177 | | |
178 | 178 | | |
179 | 179 | | |
| |||
197 | 197 | | |
198 | 198 | | |
199 | 199 | | |
200 | | - | |
201 | | - | |
| 200 | + | |
| 201 | + | |
202 | 202 | | |
203 | 203 | | |
204 | 204 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
36 | | - | |
| 36 | + | |
37 | 37 | | |
38 | | - | |
| 38 | + | |
| 39 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
298 | 298 | | |
299 | 299 | | |
300 | 300 | | |
301 | | - | |
| 301 | + | |
302 | 302 | | |
303 | 303 | | |
304 | 304 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
13 | 12 | | |
14 | 13 | | |
15 | 14 | | |
| |||
24 | 23 | | |
25 | 24 | | |
26 | 25 | | |
| 26 | + | |
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
68 | 68 | | |
69 | 69 | | |
70 | 70 | | |
71 | | - | |
| 71 | + | |
72 | 72 | | |
73 | 73 | | |
74 | 74 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
274 | 274 | | |
275 | 275 | | |
276 | 276 | | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
277 | 289 | | |
278 | 290 | | |
279 | 291 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| 23 | + | |
23 | 24 | | |
24 | | - | |
| 25 | + | |
| 26 | + | |
25 | 27 | | |
26 | 28 | | |
27 | 29 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| 23 | + | |
23 | 24 | | |
24 | | - | |
| 25 | + | |
| 26 | + | |
25 | 27 | | |
26 | 28 | | |
27 | 29 | | |
| |||
0 commit comments