Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable python warnings only for specific module via commandline

Tags:

python

When starting my Python script I'm getting this warning:

/usr/lib/python2.7/dist-packages/cffi/model.py:526: UserWarning: 'point_conversion_form_t' has no values explicitly defined; next version will refuse to guess which integer type it is meant to be (unsigned/signed, int/long)
  % self._get_c_name())

I know I can ignore this warning like this:

PYTHONWARNINGS="ignore::UserWarning" python $MYSCRIPT

But this will also ignore UserWarnings from all other modules that I would still like to see. Is it possible to specify the ignore in a more fine-grained way, like passing the module name for which warnings should be suppressed?

like image 929
Wolkenarchitekt Avatar asked Mar 05 '26 02:03

Wolkenarchitekt


1 Answers

This will ignore UserWarnings only for module cffi.model via command line:

PYTHONWARNINGS="ignore::UserWarning:cffi.model" python $MYSCRIPT
like image 74
Wolkenarchitekt Avatar answered Mar 07 '26 16:03

Wolkenarchitekt



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!