Closed
Description
Definitions
- Module
A module is a file containing Python definitions and statements. - Package
A package is a collection of modules in directories that give a package hierarchy.
Situation
The current semver.py
module contains almost 800 lines of code. As new functionality is added, the files grows bigger and bigger.
Suggested Solution
Should we consider to refactor the semver module into a package?
If yes, this is a feature which we should introduce for the upcoming 3.0.0 release. Could we label that in GitHub as such (or create a milestone)? 😉
Maybe we should also consider to refactor our test cases too and move them to a tests/
directory and create different files? They are currently almost 700 lines of code.
That issue involves the following actions:
- refactor semver module into package
- Probably introduce a
tests/
directory?
semver/
├── __main__.py # basically imports semver.cli.main and runs main()
├── __init__.py # should contain only the usual constants like __version__, __author__ etc.
├── cli.py # implements the command line interface
└── [... probably more files ...]
An example (although a bit outdated now as new commits arrived in master) can be viewed in
my fork). It's not perfect, but a start.
Pros
- Make files smaller and more readable
- No API change to the user
- Easier to add more functionality
- With
__main__.py
, it is possible to usepython -m semver -h
Cons
- More files means also, to search where a function is defined
- Slightly more difficult to test as it may be needed to run
tox
first or create a virtual environment.
What do you think? 😉
Metadata
Metadata
Assignees
Labels
Only for the major release 3Only for the major release 3