__init__ needs to be leaner and meaner

Bug #1733584 reported by Sergio Schvezov
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Snapcraft
New
Undecided
Unassigned

Bug Description

snapcraft/tests/unit/plugins/python/_basesuite.py:21: error: Name 'snapcraft.tests.unit.TestCase' is not defined
snapcraft/tests/unit/plugins/test_jhbuild.py:21: error: Name 'snapcraft.tests.unit.TestCase' is not defined
snapcraft/tests/unit/sources/test_subversion.py:28: error: Name 'unit.sources.SourceTestCase' is not defined
snapcraft/tests/unit/sources/test_mercurial.py:31: error: Name 'unit.sources.SourceTestCase' is not defined
snapcraft/tests/unit/sources/test_git.py:32: error: Name 'unit.sources.SourceTestCase' is not defined
snapcraft/tests/unit/sources/test_bazaar.py:29: error: Name 'unit.sources.SourceTestCase' is not defined

__init__.py should be used for imports only (common convention) and we should research getting rid of it all together by looking at https://www.python.org/dev/peps/pep-0420/

Answer in one of our code reviews:
"""
There are a bunch of issues in mypy related to using __init__.py, one of them is that for this to work you would need to import snapcraft.tests.unit.__init__ or something like that since it sort of works at the module level and not really at a package level. This is somewhat not urgent as it is discouraged to implement things in __init__.py in the python world.
"""

description: updated
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.