def _filter_deprecation_warnings(): """Apply filters to deprecation warnings. Force the `DeprecationWarning` warnings to be displayed for the qiskit module, overriding the system configuration as they are ignored by default [1] for end-users. Additionally, silence the `ChangedInMarshmallow3Warning` messages. TODO: on Python 3.7, this might not be needed due to PEP-0565 [2]. [1] https://docs.python.org/3/library/warnings.html#default-warning-filters [2] https://www.python.org/dev/peps/pep-0565/ """ deprecation_filter = ('always', None, DeprecationWarning, re.compile(r'^qiskit\.*', re.UNICODE), 0) # Instead of using warnings.simple_filter() directly, the internal # _add_filter() function is used for being able to match against the # module. try: warnings._add_filter(*deprecation_filter, append=False) except AttributeError: # ._add_filter is internal and not available in some Python versions. pass # Add a filter for ignoring ChangedInMarshmallow3Warning, as we depend on # marhsmallow 2 explicitly. 2.17.0 introduced new deprecation warnings that # are useful for eventually migrating, but too verbose for our purposes. warnings.simplefilter('ignore', category=ChangedInMarshmallow3Warning)
def _filter_deprecation_warnings(): """Apply filters to deprecation warnings. Force the `DeprecationWarning` warnings to be displayed for the qiskit module, overriding the system configuration as they are ignored by default [1] for end-users. Additionally, silence the `ChangedInMarshmallow3Warning` messages. TODO: on Python 3.7, this might not be needed due to PEP-0565 [2]. [1] https://docs.python.org/3/library/warnings.html#default-warning-filters [2] https://www.python.org/dev/peps/pep-0565/ """ deprecation_filter = ( "default", None, DeprecationWarning, re.compile(r"^qiskit\.*", re.UNICODE), 0, ) # Instead of using warnings.simple_filter() directly, the internal # _add_filter() function is used for being able to match against the # module. try: warnings._add_filter(*deprecation_filter, append=False) except AttributeError: # ._add_filter is internal and not available in some Python versions. pass
def _enable_deprecation_warnings(): """ Force the `DeprecationWarning` warnings to be displayed for the qiskit module, overriding the system configuration as they are ignored by default [1] for end-users. TODO: on Python 3.7, this might not be needed due to PEP-0565 [2]. [1] https://docs.python.org/3/library/warnings.html#default-warning-filters [2] https://www.python.org/dev/peps/pep-0565/ """ # pylint: disable=invalid-name deprecation_filter = ('always', None, DeprecationWarning, re.compile(r'^qiskit\.*', re.UNICODE), 0) # Instead of using warnings.simple_filter() directly, the internal # _add_filter() function is used for being able to match against the # module. warnings._add_filter(*deprecation_filter, append=False)
def _enable_deprecation_warnings(): """ Force the `DeprecationWarning` warnings to be displayed for the qiskit module, overriding the system configuration as they are ignored by default [1] for end-users. TODO: on Python 3.7, this might not be needed due to PEP-0565 [2]. [1] https://docs.python.org/3/library/warnings.html#default-warning-filters [2] https://www.python.org/dev/peps/pep-0565/ """ # pylint: disable=invalid-name deprecation_filter = ('always', None, DeprecationWarning, re.compile(r'^qiskit\.*', re.UNICODE), 0) # Instead of using warnings.simple_filter() directly, the internal # _add_filter() function is used for being able to match against the # module. warnings._add_filter(*deprecation_filter, append=False)
def spec_for_distutils(self): import importlib import importlib.abc import importlib.util import warnings # warnings.filterwarnings() imports the re module warnings._add_filter( 'ignore', _TrivialRe("distutils", "deprecated"), DeprecationWarning, None, 0, append=True ) try: mod = importlib.import_module('setuptools._distutils') except Exception: # There are a couple of cases where setuptools._distutils # may not be present: # - An older Setuptools without a local distutils is # taking precedence. Ref #2957. # - Path manipulation during sitecustomize removes # setuptools from the path but only after the hook # has been loaded. Ref #2980. # In either case, fall back to stdlib behavior. return class DistutilsLoader(importlib.abc.Loader): def create_module(self, spec): return mod def exec_module(self, module): pass return importlib.util.spec_from_loader( 'distutils', DistutilsLoader(), origin=mod.__file__ )
def update_event(self, inp=-1): self.set_output_val(0, warnings._add_filter())