From e6afd5fc8ddb339242350ab9a9912795bf490770 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=98ystein=20Olai=20Heggen?= Date: Tue, 28 Jan 2020 09:06:38 +0100 Subject: [PATCH] Add filtering on module to prevent warnings from other modules --- python/ert/__init__.py | 10 ++++++++-- python/res/__init__.py | 6 +++++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/python/ert/__init__.py b/python/ert/__init__.py index 64b22a3a08..94e27d6a30 100644 --- a/python/ert/__init__.py +++ b/python/ert/__init__.py @@ -1,8 +1,14 @@ import warnings -warnings.simplefilter('always', DeprecationWarning) # see #1437 +warnings.filterwarnings( + action='always', + category=DeprecationWarning, + module=r'ecl|ert|res' +) + warnings.warn( - "Importing from ert is deprecated and will be removed in a future release, use: \'from res import\' instead", + "Importing from ert.ecl, ecl.ecl or ert is deprecated and will not be available in python3." \ + " For eclipse functionality use \'from ecl import\', for ert workflow tooling use \'from res import\'.", DeprecationWarning ) diff --git a/python/res/__init__.py b/python/res/__init__.py index c90ac61f2f..519aad508e 100644 --- a/python/res/__init__.py +++ b/python/res/__init__.py @@ -32,7 +32,11 @@ import sys import warnings -warnings.simplefilter('always', DeprecationWarning) # see #1437 +warnings.filterwarnings( + action='always', + category=DeprecationWarning, + module=r'res|ert' +) from cwrap import load as cwrapload from cwrap import Prototype