diff --git a/python/sdist/amici/logging.py b/python/sdist/amici/logging.py index 0a345ee0a7..1f5ae1f175 100644 --- a/python/sdist/amici/logging.py +++ b/python/sdist/amici/logging.py @@ -175,7 +175,8 @@ def get_logger( elif kwargs: warnings.warn( "AMICI logger already exists, ignoring keyword " - "arguments to setup_logger" + "arguments to setup_logger", + stacklevel=2, ) logger = logging.getLogger(logger_name) diff --git a/python/sdist/amici/parameter_mapping.py b/python/sdist/amici/parameter_mapping.py index b39d54c87e..dc369b448b 100644 --- a/python/sdist/amici/parameter_mapping.py +++ b/python/sdist/amici/parameter_mapping.py @@ -27,6 +27,7 @@ warnings.warn( "Importing amici.parameter_mapping is deprecated. Use `amici.petab.parameter_mapping` instead.", DeprecationWarning, + stacklevel=2, ) __all__ = [ diff --git a/python/sdist/amici/petab/conditions.py b/python/sdist/amici/petab/conditions.py index 831420f68e..c0b702b69d 100644 --- a/python/sdist/amici/petab/conditions.py +++ b/python/sdist/amici/petab/conditions.py @@ -67,6 +67,7 @@ def fill_in_parameters( "The following problem parameters were not used: " + str(unused_parameters), RuntimeWarning, + stacklevel=2, ) for edata, mapping_for_condition in zip( diff --git a/python/sdist/amici/petab_import.py b/python/sdist/amici/petab_import.py index b81484c1cc..1bcadaa1d2 100644 --- a/python/sdist/amici/petab_import.py +++ b/python/sdist/amici/petab_import.py @@ -13,6 +13,7 @@ warnings.warn( "Importing amici.petab_import is deprecated. Use `amici.petab` instead.", DeprecationWarning, + stacklevel=2, ) from .petab.import_helpers import ( # noqa # pylint: disable=unused-import diff --git a/python/sdist/amici/petab_import_pysb.py b/python/sdist/amici/petab_import_pysb.py index a1597d53b5..4d73a4bab3 100644 --- a/python/sdist/amici/petab_import_pysb.py +++ b/python/sdist/amici/petab_import_pysb.py @@ -14,6 +14,7 @@ warnings.warn( "Importing amici.petab_import_pysb is deprecated. Use `amici.petab.pysb_import` instead.", DeprecationWarning, + stacklevel=2, ) __all__ = [ diff --git a/python/sdist/amici/petab_objective.py b/python/sdist/amici/petab_objective.py index 01724b7a7d..6d0dc44d84 100644 --- a/python/sdist/amici/petab_objective.py +++ b/python/sdist/amici/petab_objective.py @@ -12,6 +12,7 @@ warnings.warn( f"Importing {__name__} is deprecated. Use `amici.petab.simulations` instead.", DeprecationWarning, + stacklevel=2, ) from .petab.conditions import fill_in_parameters # noqa: F401 diff --git a/python/sdist/amici/petab_simulate.py b/python/sdist/amici/petab_simulate.py index 2dd25a8e4a..5f81d02a93 100644 --- a/python/sdist/amici/petab_simulate.py +++ b/python/sdist/amici/petab_simulate.py @@ -11,6 +11,7 @@ warnings.warn( f"Importing {__name__} is deprecated. Use `amici.petab.simulator` instead.", DeprecationWarning, + stacklevel=2, ) from .petab.simulator import PetabSimulator # noqa: F401 diff --git a/python/sdist/amici/petab_util.py b/python/sdist/amici/petab_util.py index ff202bf2e0..cf12a7411d 100644 --- a/python/sdist/amici/petab_util.py +++ b/python/sdist/amici/petab_util.py @@ -15,6 +15,7 @@ warnings.warn( f"Importing {__name__} is deprecated. Use `amici.petab.util` instead.", DeprecationWarning, + stacklevel=2, ) __all__ = [ diff --git a/python/sdist/amici/sbml_import.py b/python/sdist/amici/sbml_import.py index 843b954a8f..a26c6e7d4a 100644 --- a/python/sdist/amici/sbml_import.py +++ b/python/sdist/amici/sbml_import.py @@ -442,7 +442,8 @@ def sbml2amici( if not has_clibs: warnings.warn( "AMICI C++ extensions have not been built. " - "Generated model code, but unable to compile." + "Generated model code, but unable to compile.", + stacklevel=2, ) exporter.compile_model() @@ -1838,7 +1839,8 @@ def _process_event_observables( f'Event observable {eo["name"]} uses `t` in ' "it's formula which is not the time variable. " "For the time variable, please use `time` " - "instead!" + "instead!", + stacklevel=1, ) # check for nesting of observables (unsupported) @@ -2157,7 +2159,8 @@ def _get_conservation_laws_demartino( "Conservation laws for non-constant species in " "combination with parameterized stoichiometric " "coefficients are not currently supported " - "and will be turned off." + "and will be turned off.", + stacklevel=1, ) return [] @@ -2234,7 +2237,8 @@ def _get_conservation_laws_rref( "Conservation laws for non-constant species in " "combination with parameterized stoichiometric " "coefficients are not currently supported " - "and will be turned off." + "and will be turned off.", + stacklevel=1, ) return [] @@ -3048,7 +3052,8 @@ def _non_const_conservation_laws_supported(sbml_model: sbml.Model) -> bool: warnings.warn( "Conservation laws for non-constant species in " "models with RateRules are currently not supported " - "and will be turned off." + "and will be turned off.", + stacklevel=1, ) return False @@ -3060,7 +3065,8 @@ def _non_const_conservation_laws_supported(sbml_model: sbml.Model) -> bool: warnings.warn( "Conservation laws for non-constant species in " "models with Species-AssignmentRules are currently not " - "supported and will be turned off." + "supported and will be turned off.", + stacklevel=1, ) return False diff --git a/python/sdist/amici/swig_wrappers.py b/python/sdist/amici/swig_wrappers.py index 3c4df44809..5762f50bec 100644 --- a/python/sdist/amici/swig_wrappers.py +++ b/python/sdist/amici/swig_wrappers.py @@ -78,7 +78,8 @@ def runAmiciSimulation( warnings.warn( "Adjoint sensitivity analysis for models with discontinuous right hand sides (events/piecewise functions) has not been thoroughly tested." "Sensitivities might be wrong. Tracked at https://github.com/AMICI-dev/AMICI/issues/18. " - "Adjoint sensitivity analysis may work if the location of the discontinuity is not parameter-dependent, but we still recommend testing accuracy of gradients." + "Adjoint sensitivity analysis may work if the location of the discontinuity is not parameter-dependent, but we still recommend testing accuracy of gradients.", + stacklevel=1, ) with _capture_cstdout(): @@ -119,7 +120,8 @@ def runAmiciSimulations( warnings.warn( "Adjoint sensitivity analysis for models with discontinuous right hand sides (events/piecewise functions) has not been thoroughly tested. " "Sensitivities might be wrong. Tracked at https://github.com/AMICI-dev/AMICI/issues/18. " - "Adjoint sensitivity analysis may work if the location of the discontinuity is not parameter-dependent, but we still recommend testing accuracy of gradients." + "Adjoint sensitivity analysis may work if the location of the discontinuity is not parameter-dependent, but we still recommend testing accuracy of gradients.", + stacklevel=1, ) with _capture_cstdout(): diff --git a/python/sdist/pyproject.toml b/python/sdist/pyproject.toml index 58d39d4ea7..7c903273b5 100644 --- a/python/sdist/pyproject.toml +++ b/python/sdist/pyproject.toml @@ -130,4 +130,5 @@ line-length = 79 extend-include = ["*.ipynb"] [tool.ruff.lint] +extend-select = ["B028"] ignore = ["E402", "F403", "F405", "E741"]