Changelog
If you've never used Poetry, think of it as NPM, but for Python. Cross-platform and dead-easy to install. It's also great for packing up your project and distributing it, and it also ensures that each of your Python projects contain their own virtual environment so you don't pollute the global install with dependencies from every single project you work on. It's a really nifty tool and does quite a bit.
Added Black with 120 LL
Basically just to keep formatting consistent. You may want to tone down the line length to whatever suits your project as you see it. I would also recommend adding it as a git hook along with flake8 in the future if you plan to develop this further.
Bumped Python to 3.9.1 for latest feature support and better typing out of the box
Not much to say here, but you ideally really wanna start with the latest version as it comes with too many goodies and fixes to ignore.
config.py
Changed the way you construct config to include typed classes and still be fed by a user-editable object.
My argument for this would be simply that it's far harder to introduce a crap value into your config when the linter will pick up a type mismatch, plus you get some level of control by being able to now extend each class with error handling and validation if you wish to do so. For the time being I only added some __repr__
methods for debug purposes.
coin.py
The methods you had there, while not exactly a sin, did nothing that coin.param = "someval"
would not do, since that was all you did with them, I removed them completely. I also typed all those params for you. Also moved the specificity of coin types out of this class and into the config object.
cryptoportfoliotracker.py
- Mainly changed the
get_coins
method to support the "slimmer" coin class and made the construction of coins less repetitive (one for loop rather than two near-identical ones).
- Moved the driver value out of the
get_driver
method and into the config, that way someone can set it as another value and use it on Linux or MacOS as that is really the only thing that dictates which platform it all works on.
- Typing and formatting changes.
Misc changes
- Amended readme to reflect the changes and also added how to install this project via poetry. I have intentionally left the packing bit out for you to decide if you wanna go down that way or if a simple
clone>poetry install
is sufficient.
- Changed the
.bat
file, it's enough to just write the below as it will be executed in the same folder so in that run context, simply saying poetry run..
is enough to fire off your project in Windows.
poetry run python cryptoportfoliotracker.py
pause
cli.py
- small changes related to typing and formatting.
In closing
I just wanted to contribute some extra stuff here which may get you to pick up some of these tools / work patterns in future python projects. I also tried my best not to remove / rework so much that it no longer looks like your work. In that spirit, I left plenty of things alone which you can yourself choose to change/improve, such as validation, error handling, logging (cough cough Loguru), moving everything into a proper module and so on. I hope you like these changes. But no worries if you choose not to merge this.