Hi,

I'm looking for a way to import __version__ / __author__ into my __init__.py 
without causing an F401 error.

Defining __version__ normally works fine:

> init.py

    __version__ = '1.0.0'
    __author__ = 'Jack Wilsdon <jack.wils...@gmail.com>

But if I define them in an external file and import them, I get an F401 error:

> __version__.py

    __version__ = '1.0.0'
    __author__ = 'Jack Wilsdon <jack.wils...@gmail.com>

> init.py

    from __version__ import __version__, __author__  # I get an F

> flake8 __init__.py

    __init__.py:1:1: F401 '__version.__author__' imported but unused
    __init__.py:1:1: F401 '__version.__version__' imported but unused

Is there anything I can do about this? I know I could add "# noqa: F401" to the 
end of the import, but it just feels like a bit of a "hack" to me.

I could also add __version__ and __author__ to __all__ in init.py, but then 
they would be imported if anyone used "from my_module import *", which is 
definitely not what I want.

Is this a bug in flake8/pyflakes or just my understanding of how __version__ 
and __author__ are exempt from F401 errors normally.

Thanks,
Jack
_______________________________________________
code-quality mailing list
code-quality@python.org
https://mail.python.org/mailman/listinfo/code-quality

Reply via email to