Skip to content

Commit f5a3485

Browse files
committedMar 28, 2019
Fix some Python warnings, avoid accidently hiding all deprecation warnings
1 parent 234c171 commit f5a3485

File tree

7 files changed

+13
-12
lines changed

7 files changed

+13
-12
lines changed
 

‎python/plugins/MetaSearch/dialogs/newconnectiondialog.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
#
2828
###############################################################################
2929

30-
import warnings
3130
from qgis.core import QgsSettings
3231
from qgis.PyQt.QtWidgets import QDialog, QMessageBox
3332

‎python/plugins/MetaSearch/util.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,6 @@
2424
#
2525
###############################################################################
2626

27-
# avoid PendingDeprecationWarning from qgis.PyQt.uic
28-
import warnings
29-
warnings.filterwarnings("ignore", category=PendingDeprecationWarning)
30-
warnings.filterwarnings("ignore", category=DeprecationWarning)
31-
3227
from gettext import gettext, ngettext
3328
import logging
3429
import os

‎python/plugins/processing/algs/grass7/Grass7Algorithm.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,11 @@
6464
QgsVectorLayer,
6565
QgsProviderRegistry)
6666
from qgis.utils import iface
67-
from osgeo import ogr
67+
68+
import warnings
69+
with warnings.catch_warnings():
70+
warnings.filterwarnings("ignore", category=DeprecationWarning)
71+
from osgeo import ogr
6872

6973
from processing.core.ProcessingConfig import ProcessingConfig
7074

‎python/plugins/processing/algs/help/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def loadShortHelp():
4343
with codecs.open(filename, encoding='utf-8') as stream:
4444
with warnings.catch_warnings():
4545
warnings.filterwarnings("ignore", category=DeprecationWarning)
46-
for k, v in yaml.load(stream).items():
46+
for k, v in yaml.load(stream, Loader=yaml.SafeLoader).items():
4747
if v is None:
4848
continue
4949
h[k] = QCoreApplication.translate("{}Algorithm".format(f[:-5].upper()), v)

‎python/plugins/processing/algs/qgis/Datasources2Vrt.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,10 @@
2828
import codecs
2929
import xml.sax.saxutils
3030

31-
from osgeo import ogr
31+
import warnings
32+
with warnings.catch_warnings():
33+
warnings.filterwarnings("ignore", category=DeprecationWarning)
34+
from osgeo import ogr
3235
from qgis.core import (QgsProcessingFeedback,
3336
QgsProcessingParameterMultipleLayers,
3437
QgsProcessingParameterBoolean,

‎python/plugins/processing/gui/wrappers.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1902,7 +1902,7 @@ def setValue(self, value):
19021902

19031903
for v in value:
19041904
for i, opt in enumerate(options):
1905-
match = re.search('(?:\A|[^0-9]){}(?:\Z|[^0-9]|)'.format(v), opt)
1905+
match = re.search('(?:\\A|[^0-9]){}(?:\\Z|[^0-9]|)'.format(v), opt)
19061906
if match:
19071907
selected.append(i)
19081908

@@ -1917,7 +1917,7 @@ def value(self):
19171917
if self.parameterDefinition().allowMultiple():
19181918
bands = []
19191919
for i in self.widget.selectedoptions:
1920-
match = re.search('(?:\A|[^0-9])([0-9]+)(?:\Z|[^0-9]|)', self.widget.options[i])
1920+
match = re.search('(?:\\A|[^0-9])([0-9]+)(?:\\Z|[^0-9]|)', self.widget.options[i])
19211921
if match:
19221922
bands.append(match.group(1))
19231923
return bands

‎python/plugins/processing/tests/AlgorithmsTestBase.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ def test_algorithms(self):
7272
This is the main test function. All others will be executed based on the definitions in testdata/algorithm_tests.yaml
7373
"""
7474
with open(os.path.join(processingTestDataPath(), self.test_definition_file()), 'r') as stream:
75-
algorithm_tests = yaml.load(stream)
75+
algorithm_tests = yaml.load(stream, Loader=yaml.SafeLoader)
7676

7777
if 'tests' in algorithm_tests and algorithm_tests['tests'] is not None:
7878
for idx, algtest in enumerate(algorithm_tests['tests']):

0 commit comments

Comments
 (0)
Please sign in to comment.