Skip to content

Refactor mkchromecast to make __init__.py minimal and avoid import __init__ #425

@xsdg

Description

@xsdg

As implemented, there's a lot of work being done in __init__.py that should be done elsewhere.

  • Argument parsing should be done directly in bin/mkchromecast
  • The mkchromecast library should be designed as a library, with one or more classes that encapsulate the functionality, can be instantiated with appropriate arguments, and can be unit-tested independently
  • Many of the python files in mkchromecast use import mkchromecast.__init__. This is a code smell. Especially given that mkchromecast is a binary + library pair, __init__.py shouldn't do any work, and should only present the external API of the library. The modules in the library should import things directly, and shouldn't pass back through __init__.py.
  • __init__.py is used in this way because mkchromecast uses a lot of global variables and very little encapsulation. This is also a code smell, and makes the code difficult to unit test effectively.

Metadata

Metadata

Assignees

Labels

codehealthTasks focused on improving the maintainability of the codebase

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions