Skip to content
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

Add stacklevel to warnings #2421

Merged
merged 2 commits into from
May 3, 2024
Merged

Conversation

dweindl
Copy link
Member

@dweindl dweindl commented May 2, 2024

Make it easier to find out where warnings originate from.

Make it easier to find out where warnings originate from.
@dweindl dweindl requested a review from a team as a code owner May 2, 2024 15:31
Copy link

codecov bot commented May 2, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 77.60%. Comparing base (6b05ddd) to head (7bdeb07).

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #2421      +/-   ##
===========================================
- Coverage    77.63%   77.60%   -0.03%     
===========================================
  Files          324      324              
  Lines        20913    20913              
  Branches      1464     1464              
===========================================
- Hits         16236    16230       -6     
- Misses        4674     4680       +6     
  Partials         3        3              
Flag Coverage Δ
cpp 73.38% <ø> (-0.03%) ⬇️
cpp_python 34.12% <ø> (ø)
petab 36.70% <ø> (ø)
python 72.14% <ø> (-0.03%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
python/sdist/amici/logging.py 79.16% <ø> (ø)
python/sdist/amici/parameter_mapping.py 0.00% <ø> (ø)
python/sdist/amici/petab/conditions.py 97.43% <ø> (ø)
python/sdist/amici/petab_objective.py 0.00% <ø> (ø)
python/sdist/amici/petab_simulate.py 0.00% <ø> (ø)
python/sdist/amici/petab_util.py 0.00% <ø> (ø)
python/sdist/amici/sbml_import.py 78.77% <ø> (ø)
python/sdist/amici/swig_wrappers.py 92.42% <ø> (ø)

... and 2 files with indirect coverage changes

@dweindl dweindl enabled auto-merge May 2, 2024 16:59
@FFroehlich
Copy link
Member

Hmm, is it not possible to manage this using a context manager? Seems rather difficult to keep stack levels cohesive throughout the package.

@dweindl
Copy link
Member Author

dweindl commented May 3, 2024

Hmm, is it not possible to manage this using a context manager? Seems rather difficult to keep stack levels cohesive throughout the package.

Finding the precise frame / code location where some deprecated argument is introduced is overkill in my opinion.

For the module-level deprecation warnings, stacklevel=2 always makes sense, because this will show the location of the deprecated import statement.

@FFroehlich
Copy link
Member

Hmm, is it not possible to manage this using a context manager? Seems rather difficult to keep stack levels cohesive throughout the package.

Finding the precise frame / code location where some deprecated argument is introduced is overkill in my opinion.

For the module-level deprecation warnings, stacklevel=2 always makes sense, because this will show the location of the deprecated import statement.

Yes, my concern is more that the next time we add a warning, we will forget to add the stacklevel=2 argument.

@dweindl
Copy link
Member Author

dweindl commented May 3, 2024

my concern is more that the next time we add a warning, we will forget to add the stacklevel=2 argument.

Oh, no worries, I'm happy to add a reminder: https://docs.astral.sh/ruff/rules/no-explicit-stacklevel/

@dweindl dweindl added this pull request to the merge queue May 3, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks May 3, 2024
@dweindl dweindl merged commit 8c3b59a into AMICI-dev:develop May 3, 2024
25 of 26 checks passed
@dweindl dweindl deleted the warn_stacklvl branch May 3, 2024 13:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants