pylint-bot / test

0 stars 0 forks source link

[easy] Consider using scandir in modutils again #218

Open pylint-bot opened 8 years ago

pylint-bot commented 8 years ago

Originally reported by: BitBucket: ceridwenv, GitHub: @ceridwen?


With scandir now in the 3.5 stdlib and some progress on PyPy compatibility (there's a pull request at https://github.com/benhoyt/scandir/pull/53), it might be worth revisiting the use of scandir in modutils, if necessary in a conditional way.


pylint-bot commented 8 years ago

Original comment by Claudiu Popa (BitBucket: PCManticore, GitHub: @PCManticore?):


Sounds good! scandir is also backported to Python 2, why is it necessary to be used in a conditional way?

pylint-bot commented 8 years ago

Original comment by BitBucket: ceridwenv, GitHub: @ceridwen?:


Because it's now in the stdlib, we have to use the same pattern as for singledispatch. If PyPy compatibility is broken too,

try:
    from os import scandir, walk
except ImportError:
    if platform.python_implementation = 'Cpython':
         from scandir import scandir, walk
    else:
         from os import walk

Or something like that.