Patchwork [10,of,10] import-checker: drop workaround for pure modules

login
register
mail settings
Submitter Yuya Nishihara
Date May 20, 2017, 8:41 a.m.
Message ID <c0145420aa315db622db.1495269677@mimosa>
Download mbox | patch
Permalink /patch/20770/
State Accepted
Headers show

Comments

Yuya Nishihara - May 20, 2017, 8:41 a.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1471058993 -32400
#      Sat Aug 13 12:29:53 2016 +0900
# Node ID c0145420aa315db622dbad82c1f426d757a0066a
# Parent  fcb32be15135d41e100bc5add773c08b5b63e8e9
import-checker: drop workaround for pure modules

Patch

diff --git a/contrib/check-py3-compat.py b/contrib/check-py3-compat.py
--- a/contrib/check-py3-compat.py
+++ b/contrib/check-py3-compat.py
@@ -15,10 +15,6 @@  import os
 import sys
 import traceback
 
-# Modules that have both Python and C implementations.
-_dualmodules = (
-)
-
 def check_compat_py2(f):
     """Check Python 3 compatibility for a file with Python 2"""
     with open(f, 'rb') as fh:
@@ -60,8 +56,6 @@  def check_compat_py3(f):
     if f.startswith(('hgext/', 'mercurial/')) and not f.endswith('__init__.py'):
         assert f.endswith('.py')
         name = f.replace('/', '.')[:-3]
-        if f.endswith(_dualmodules):
-            name = name.replace('.pure.', '.')
         try:
             importlib.import_module(name)
         except Exception as e:
diff --git a/contrib/import-checker.py b/contrib/import-checker.py
--- a/contrib/import-checker.py
+++ b/contrib/import-checker.py
@@ -24,10 +24,6 @@  allowsymbolimports = (
     'mercurial.node',
 )
 
-# Modules that have both Python and C implementations.
-_dualmodules = (
-)
-
 # Modules that must be aliased because they are commonly confused with
 # common variables and can create aliasing and readability issues.
 requirealias = {
@@ -59,13 +55,11 @@  def walklocal(root):
             todo.extend(ast.iter_child_nodes(node))
         yield node, newscope
 
-def dotted_name_of_path(path, trimpure=False):
+def dotted_name_of_path(path):
     """Given a relative path to a source file, return its dotted module name.
 
     >>> dotted_name_of_path('mercurial/error.py')
     'mercurial.error'
-    >>> dotted_name_of_path('mercurial/pure/parsers.py', trimpure=True)
-    'mercurial.parsers'
     >>> dotted_name_of_path('zlibmodule.so')
     'zlib'
     """
@@ -73,8 +67,6 @@  def dotted_name_of_path(path, trimpure=F
     parts[-1] = parts[-1].split('.', 1)[0] # remove .py and .so and .ARCH.so
     if parts[-1].endswith('module'):
         parts[-1] = parts[-1][:-6]
-    if trimpure:
-        return '.'.join(p for p in parts if p != 'pure')
     return '.'.join(parts)
 
 def fromlocalfunc(modulename, localmods):
@@ -695,8 +687,7 @@  def main(argv):
     used_imports = {}
     any_errors = False
     for source_path in argv[1:]:
-        trimpure = source_path.endswith(_dualmodules)
-        modname = dotted_name_of_path(source_path, trimpure=trimpure)
+        modname = dotted_name_of_path(source_path)
         localmods[modname] = source_path
     for localmodname, source_path in sorted(localmods.items()):
         for src, modname, name, line in sources(source_path, localmodname):