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

Change default stacklevel for deprecation warning #3959

Merged

Conversation

jenshnielsen
Copy link
Collaborator

Level 2 is inside decorate_callable e.g. one level up from the warning
Level 3 is the call that actually triggers the warning
e.g. two levels up from the warning

For example if I were to deprecate dataset.parameters and run the test suite
the warnings before would be.

qcodes/tests/dataset/test_dataset_basic.py: 3 warnings
qcodes/tests/dataset/test_database_extract_runs.py: 22 warnings
qcodes/tests/dataset/test_database_creation_and_upgrading.py: 2 warnings
qcodes/tests/dataset/test_dataset_loading.py: 2 warnings
qcodes/tests/dataset/test_doNd.py: 7 warnings
qcodes/tests/dataset/measurement/test_measurement_context_manager.py: 24 warnings
  C:\Users\jenielse\source\repos\Qcodes\qcodes\utils\deprecate.py:59: QCoDeSDeprecationWarning: The function <parameters> is deprecated. Use "dataset.rundescriber.parameters" as an alternative.
    issue_deprecation_warning(f'{t} <{n}>', reason, alternative)

With this fix its

qcodes/tests/dataset/test_dataset_basic.py::test_has_attributes_after_init
  C:\Users\jenielse\source\repos\Qcodes\qcodes\tests\dataset\test_dataset_basic.py:68: QCoDeSDeprecationWarning: The function <parameters> is deprecated. Use "dataset.rundescriber.parameters" as an alternative.
    assert hasattr(ds, attr)

qcodes/tests/dataset/test_dataset_basic.py::test_has_attributes_after_init
  C:\Users\jenielse\source\repos\Qcodes\qcodes\tests\dataset\test_dataset_basic.py:69: QCoDeSDeprecationWarning: The function <parameters> is deprecated. Use "dataset.rundescriber.parameters" as an alternative.
    getattr(ds, attr)

qcodes/tests/dataset/test_dataset_basic.py::test_has_attributes_after_init
  C:\Users\jenielse\source\repos\Qcodes\qcodes\tests\dataset\test_dataset_basic.py:74: QCoDeSDeprecationWarning: The function <parameters> is deprecated. Use "dataset.rundescriber.parameters" as an alternative.
    assert hasattr(ds, attr)

qcodes/tests/dataset/test_dataset_basic.py::test_has_attributes_after_init
  C:\Users\jenielse\source\repos\Qcodes\qcodes\tests\dataset\test_dataset_basic.py:75: QCoDeSDeprecationWarning: The function <parameters> is deprecated. Use "dataset.rundescriber.parameters" as an alternative.
    getattr(ds, attr)

qcodes/tests/dataset/test_dataset_basic.py::test_the_same_dataset_as
  C:\Users\jenielse\source\repos\Qcodes\qcodes\dataset\data_set_protocol.py:318: QCoDeSDeprecationWarning: The function <parameters> is deprecated. Use "dataset.rundescriber.parameters" as an alternative.
    if getattr(self, attr) != getattr(other, attr):

qcodes/tests/dataset/test_dataset_basic.py::test_empty_ds_parameters
  C:\Users\jenielse\source\repos\Qcodes\qcodes\tests\dataset\test_dataset_basic.py:1284: QCoDeSDeprecationWarning: The function <parameters> is deprecated. Use "dataset.rundescriber.parameters" as an alternative.
    assert ds.parameters is None

qcodes/tests/dataset/test_dataset_basic.py::test_empty_ds_parameters
  C:\Users\jenielse\source\repos\Qcodes\qcodes\tests\dataset\test_dataset_basic.py:1286: QCoDeSDeprecationWarning: The function <parameters> is deprecated. Use "dataset.rundescriber.parameters" as an alternative.
    assert ds.parameters is None

qcodes/tests/dataset/test_dataset_basic.py::test_empty_ds_parameters
  C:\Users\jenielse\source\repos\Qcodes\qcodes\tests\dataset\test_dataset_basic.py:1288: QCoDeSDeprecationWarning: The function <parameters> is deprecated. Use "dataset.rundescriber.parameters" as an alternative.
    assert ds.parameters is None

....

@jenshnielsen
Copy link
Collaborator Author

Should probably add a news fragment

@codecov
Copy link

codecov bot commented Feb 25, 2022

Codecov Report

Merging #3959 (8c36806) into master (ef0d31b) will not change coverage.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##           master    #3959   +/-   ##
=======================================
  Coverage   65.83%   65.83%           
=======================================
  Files         228      228           
  Lines       31464    31464           
=======================================
  Hits        20714    20714           
  Misses      10750    10750           

@jenshnielsen jenshnielsen added this to the 0.33.0 milestone Feb 25, 2022
Level 2 is inside decorate_callable e.g. one level up from the warning
Level 3 is the call that actually triggers the warning
e.g. two levels up from the warning
@jenshnielsen jenshnielsen force-pushed the better_deprecation_warning branch from 08b153d to 4dfc100 Compare February 25, 2022 10:53
@jenshnielsen jenshnielsen merged commit 8305325 into microsoft:master Feb 25, 2022
@jenshnielsen jenshnielsen deleted the better_deprecation_warning branch February 25, 2022 11:47
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