Search code examples
pythonpep8flake8

Flake8 with pep8-naming complains about camelCase imports


I tried using the following:

import xml.etree.ElementTree as ET

but flake8 with pep8-naming gives the following warning:

N817 camelcase 'xml.etree.ElementTree' imported as acronym 'ET'

then I tried:

import xml.etree.ElementTree as et
import xml.etree.ElementTree as element_tree

but yet again:

N813 camelcase 'xml.etree.ElementTree' imported as lowercase 'et'

What does flake8 want here?


Solution

  • Flake8 is ok with the following acronyms:

    import xml.etree.ElementTree as Et
    import xml.etree.ElementTree as eT
    

    More verbose variants are also possible:

    import xml.etree.ElementTree as ETree
    import xml.etree.ElementTree as eTree
    import xml.etree.ElementTree as ElementTree