pycodestyle icon indicating copy to clipboard operation
pycodestyle copied to clipboard

E128: confusion with variable-length encoding (like UTF-8)

Open ronanpaixao opened this issue 10 years ago • 4 comments

E128 gets confused with variable-lenght (with multi-byte) encoding, such as UTF-8. Using a multi-byte character makes PEP8 return an E128 warning of under-indent. Tests show that it expects one more space for each multi-byte character, consistent with UTF-8 double-bytes for the extended I'm using.

Apparently PEP8 is either ignoring the shebang line or using len() directly with UTF-8 string without converting to unicode first (even with the 'u' prefix).

Example pep8utf8.py:

# -*- coding: utf-8 -*-
_EPSILON = {'pressao': {'psig': 1,
                        'kPag': 5},  # No error here
            'pressão': {'psig': 1,
                        'kPag': 5},  # Error
            }

Running pep8 --show-source pep8utf8.py yields:

pep8utf8.py:5:25: E128 continuation line under-indented for visual indent
                        'kPag': 5},  # Error
                        ^

Note 1: I have tried using unicode strings, but the error is still there. Note 2: Python 2.7.6 |Anaconda 2.1.0 (32-bit)| (default, Nov 11 2013, 10:50:31) [MSC v.1500 32 bit (Intel)] on win32

ronanpaixao avatar Mar 12 '15 17:03 ronanpaixao