Skip to content

Commit d1cdfa0

Browse files
committed
A bit of cleanup based on pylint warnings. Namely, merge the duplicate
definitions of force_native_str_rec to use the existing active one and remove the duplicate import of basestring.
1 parent cb0604d commit d1cdfa0

File tree

1 file changed

+6
-15
lines changed

1 file changed

+6
-15
lines changed

mig/shared/base.py

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# --- BEGIN_HEADER ---
55
#
66
# base - shared base helper functions
7-
# Copyright (C) 2003-2024 The MiG Project by the Science HPC Center at UCPH
7+
# Copyright (C) 2003-2025 The MiG Project by the Science HPC Center at UCPH
88
#
99
# This file is part of MiG.
1010
#
@@ -29,7 +29,6 @@
2929

3030
from __future__ import print_function
3131
from __future__ import absolute_import
32-
from past.builtins import basestring
3332

3433
from builtins import range
3534
from past.builtins import basestring
@@ -654,12 +653,14 @@ def _force_default_coding_rec(input_obj, kind, highlight='', stringify=False):
654653
raise ValueError('Unsupported default coding kind: %s' % kind)
655654

656655

657-
def force_native_str_rec(input_obj, highlight=''):
658-
"""A helper to force input_obj to the default string coding.
656+
def force_native_str_rec(input_obj, highlight='', stringify=False):
657+
"""A helper to force input_obj to the default string coding recursively.
659658
Use the active interpreter and the shared.defaults helpers to force the
660659
current default.
660+
Please note that the default here is to NOT stringify non-string values
661+
like numbers.
661662
"""
662-
return _force_default_coding_rec(input_obj, STR_KIND, highlight)
663+
return _force_default_coding_rec(input_obj, STR_KIND, highlight, stringify)
663664

664665

665666
def force_default_str_coding_rec(input_obj, highlight='', stringify=False):
@@ -682,16 +683,6 @@ def force_default_fs_coding_rec(input_obj, highlight='', stringify=False):
682683
return _force_default_coding_rec(input_obj, FS_KIND, highlight, stringify)
683684

684685

685-
def force_native_str_rec(input_obj, highlight='', stringify=False):
686-
"""A helper to force input_obj to the default string coding recursively.
687-
Use the active interpreter and the shared.defaults helpers to force the
688-
current default.
689-
Please note that the default here is to NOT stringify non-string values
690-
like numbers.
691-
"""
692-
return _force_default_coding_rec(input_obj, STR_KIND, highlight, stringify)
693-
694-
695686
def native_str_escape(val):
696687
"""applies either the .encode('string_escape') or .encode('unicode_escape')
697688
depending on the native string format, to escape existing backslashes like

0 commit comments

Comments
 (0)