Navigation Menu

Skip to content

Commit

Permalink
Fix some Python warnings, avoid accidently hiding all deprecation war…
Browse files Browse the repository at this point in the history
…nings
  • Loading branch information
nyalldawson committed Mar 28, 2019
1 parent 234c171 commit f5a3485
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 12 deletions.
1 change: 0 additions & 1 deletion python/plugins/MetaSearch/dialogs/newconnectiondialog.py
Expand Up @@ -27,7 +27,6 @@
#
###############################################################################

import warnings
from qgis.core import QgsSettings
from qgis.PyQt.QtWidgets import QDialog, QMessageBox

Expand Down
5 changes: 0 additions & 5 deletions python/plugins/MetaSearch/util.py
Expand Up @@ -24,11 +24,6 @@
#
###############################################################################

# avoid PendingDeprecationWarning from qgis.PyQt.uic
import warnings
warnings.filterwarnings("ignore", category=PendingDeprecationWarning)
warnings.filterwarnings("ignore", category=DeprecationWarning)

from gettext import gettext, ngettext
import logging
import os
Expand Down
6 changes: 5 additions & 1 deletion python/plugins/processing/algs/grass7/Grass7Algorithm.py
Expand Up @@ -64,7 +64,11 @@
QgsVectorLayer,
QgsProviderRegistry)
from qgis.utils import iface
from osgeo import ogr

import warnings
with warnings.catch_warnings():
warnings.filterwarnings("ignore", category=DeprecationWarning)
from osgeo import ogr

from processing.core.ProcessingConfig import ProcessingConfig

Expand Down
2 changes: 1 addition & 1 deletion python/plugins/processing/algs/help/__init__.py
Expand Up @@ -43,7 +43,7 @@ def loadShortHelp():
with codecs.open(filename, encoding='utf-8') as stream:
with warnings.catch_warnings():
warnings.filterwarnings("ignore", category=DeprecationWarning)
for k, v in yaml.load(stream).items():
for k, v in yaml.load(stream, Loader=yaml.SafeLoader).items():
if v is None:
continue
h[k] = QCoreApplication.translate("{}Algorithm".format(f[:-5].upper()), v)
Expand Down
5 changes: 4 additions & 1 deletion python/plugins/processing/algs/qgis/Datasources2Vrt.py
Expand Up @@ -28,7 +28,10 @@
import codecs
import xml.sax.saxutils

from osgeo import ogr
import warnings
with warnings.catch_warnings():
warnings.filterwarnings("ignore", category=DeprecationWarning)
from osgeo import ogr
from qgis.core import (QgsProcessingFeedback,
QgsProcessingParameterMultipleLayers,
QgsProcessingParameterBoolean,
Expand Down
4 changes: 2 additions & 2 deletions python/plugins/processing/gui/wrappers.py
Expand Up @@ -1902,7 +1902,7 @@ def setValue(self, value):

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

Expand All @@ -1917,7 +1917,7 @@ def value(self):
if self.parameterDefinition().allowMultiple():
bands = []
for i in self.widget.selectedoptions:
match = re.search('(?:\A|[^0-9])([0-9]+)(?:\Z|[^0-9]|)', self.widget.options[i])
match = re.search('(?:\\A|[^0-9])([0-9]+)(?:\\Z|[^0-9]|)', self.widget.options[i])
if match:
bands.append(match.group(1))
return bands
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/processing/tests/AlgorithmsTestBase.py
Expand Up @@ -72,7 +72,7 @@ def test_algorithms(self):
This is the main test function. All others will be executed based on the definitions in testdata/algorithm_tests.yaml
"""
with open(os.path.join(processingTestDataPath(), self.test_definition_file()), 'r') as stream:
algorithm_tests = yaml.load(stream)
algorithm_tests = yaml.load(stream, Loader=yaml.SafeLoader)

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

0 comments on commit f5a3485

Please sign in to comment.