ColinDuquesnoy / QDarkStyleSheet

A dark style sheet for QtWidgets application
Other
2.76k stars 725 forks source link

Incorrect modification to warnings #325

Closed cliffckerr closed 8 months ago

cliffckerr commented 1 year ago

It appears this commit: https://github.com/ColinDuquesnoy/QDarkStyleSheet/commit/73531859fef3931428b9c74ed7ac2ccf596d19df

inadvertently introduced a bug. The issue (https://github.com/ColinDuquesnoy/QDarkStyleSheet/issues/309) referred to the logging module, not the warnings module. warnings.warning() does not exist:

    dark_qss = qdarkstyle.load_stylesheet_from_environment()
  File "/software/mambaforge/envs/tmpspy/lib/python3.7/site-packages/qdarkstyle/__init__.py", line 437, in load_stylesheet_from_environment
    warnings.warning(DEPRECATION_MSG, DeprecationWarning)
AttributeError: module 'warnings' has no attribute 'warning'

The bug can be fixed by reverting that commit. (There may be some other location in the code where logging.warn() is being used instead of logging.warning(), but it should definitely be warnings.warn(), not warnings.warning()!)

Describe Your Environment

Please, report the output of the command (from v2.6+) or fill the information below:

$ qdarkstyle --all

* OPERATING SYSTEM---------------------------------------------------------------
    - System........................ Linux
    - Release....................... 5.15.0-53-generic
    - Platform...................... Linux-5.15.0-53-generic-x86_64-with-glibc2.35
    - Version....................... #59-Ubuntu SMP Mon Oct 17 18:53:30 UTC 2022
* PYTHON DISTRIBUTION------------------------------------------------------------
    - Version....................... 3.10.6
    - C Compiler.................... GCC 10.4.0
    - C API Version................. 1013
    - Implementation................ cpython
    - Implementation Version........ 3.10.6
* QT BINDINGS--------------------------------------------------------------------
    - PyQt5 Version................. 5.15.7
    - PyQt5 Qt Version.............. 5.15.2
* QT ABSTRACTIONS----------------------------------------------------------------
    - qtpy Version.................. 2.3.0
    - qtpy Binding.................. pyqt5
    - qtpy Binding Variable......... os.environ['QT_API']
    - qtpy Import Name.............. qtpy
    - qtpy Status................... OK
* PYTHON PACKAGES----------------------------------------------------------------
    - helpdev....................... 0.7.1
    - QDarkStyle.................... 3.0.3

Language

Python

Steps to reproduce

Complicated; I encountered this while trying to debug why the Spyder Notebook plugin didn't work, so some complicated series of mamba install commands using deprecated versions of various packages uncovered this bug :)

dpizetta commented 8 months ago

Thanks for reporting this @cliffckerr. Fixed :)