Skip to contentSkip to conversation

utils/check-package: use explicit relative imports

PATCH New Titouan Christophe 2 participants 2 messages Jan 15, 2019 – Jan 16, 2019

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 utils/check-package: use explicit relative imports

The syntax for explicit relative imports was introduced in Python2.6, and the implicit relative imports were removed in Python3.

According to PEP394, Python source files that use the python shebang line should be compatible with both Python2 and Python3. With this patch, users of distros where Python3 is the default are able to use check-package

---
 utils/checkpackagelib/lib.py        |  2 +-
 utils/checkpackagelib/lib_config.py | 10 +++++-----
 utils/checkpackagelib/lib_hash.py   | 10 +++++-----
 utils/checkpackagelib/lib_mk.py     | 10 +++++-----
 utils/checkpackagelib/lib_patch.py  |  4 ++--
 5 files changed, 18 insertions(+), 18 deletions(-)
utils/checkpackagelib/lib.py +1 -1
index 91f4ad49b7..06b147a470 100644
@@ -1,6 +1,6 @@
 # See utils/checkpackagelib/readme.txt before editing this file.
 
-from base import _CheckFunction
+from .base import _CheckFunction
 
 
 class ConsecutiveEmptyLines(_CheckFunction):
utils/checkpackagelib/lib_config.py +5 -5
index 1d273f1c5f..f6dc583a08 100644
@@ -5,11 +5,11 @@
 
 import re
 
-from base import _CheckFunction
-from lib import ConsecutiveEmptyLines  # noqa: F401
-from lib import EmptyLastLine          # noqa: F401
-from lib import NewlineAtEof           # noqa: F401
-from lib import TrailingSpace          # noqa: F401
+from .base import _CheckFunction
+from .lib import ConsecutiveEmptyLines  # noqa: F401
+from .lib import EmptyLastLine          # noqa: F401
+from .lib import NewlineAtEof           # noqa: F401
+from .lib import TrailingSpace          # noqa: F401
 
 
 def _empty_or_comment(text):
utils/checkpackagelib/lib_hash.py +5 -5
index 6d4cc9fd62..3ddd88bae9 100644
@@ -5,11 +5,11 @@
 
 import re
 
-from base import _CheckFunction
-from lib import ConsecutiveEmptyLines  # noqa: F401
-from lib import EmptyLastLine          # noqa: F401
-from lib import NewlineAtEof           # noqa: F401
-from lib import TrailingSpace          # noqa: F401
+from .base import _CheckFunction
+from .lib import ConsecutiveEmptyLines  # noqa: F401
+from .lib import EmptyLastLine          # noqa: F401
+from .lib import NewlineAtEof           # noqa: F401
+from .lib import TrailingSpace          # noqa: F401
 
 
 def _empty_line_or_comment(text):
utils/checkpackagelib/lib_mk.py +5 -5
index 0e430a2f12..857d7b16ad 100644
@@ -6,11 +6,11 @@
 
 import re
 
-from base import _CheckFunction
-from lib import ConsecutiveEmptyLines  # noqa: F401
-from lib import EmptyLastLine          # noqa: F401
-from lib import NewlineAtEof           # noqa: F401
-from lib import TrailingSpace          # noqa: F401
+from .base import _CheckFunction
+from .lib import ConsecutiveEmptyLines  # noqa: F401
+from .lib import EmptyLastLine          # noqa: F401
+from .lib import NewlineAtEof           # noqa: F401
+from .lib import TrailingSpace          # noqa: F401
 
 
 class Indent(_CheckFunction):
utils/checkpackagelib/lib_patch.py +2 -2
index 555621afa1..4b1b48e6ca 100644
@@ -5,8 +5,8 @@
 
 import re
 
-from base import _CheckFunction
-from lib import NewlineAtEof           # noqa: F401
+from .base import _CheckFunction
+from .lib import NewlineAtEof           # noqa: F401
 
 
 class ApplyOrder(_CheckFunction):
Signature · 1 line
2.19.2
#1 lore raw

PATCH 1/1 utils/check-package: use explicit relative imports

Quoted 6 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Titouan" == Titouan Christophe <[email protected]> writes:

The syntax for explicit relative imports was introduced in Python2.6, and the implicit relative imports were removed in Python3.

Quoted 6 lines

According to PEP394, Python source files that use the python shebang line should be compatible with both Python2 and Python3. With this patch, users of distros where Python3 is the default are able to use check-package

Thanks, but I have instead applied Ricardo's patch:

https://patchwork.ozlabs.org/patch/956517/

Signature · 1 line
Bye, Peter Korsgaard