Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Move the code to a
src/caskdb/
folder, for packaging and testing convenience (will come back to this later)Change the module imports to be
from caskdb.disk_store import ...
Added
__init__.py
with__all__
to specify the public API offrom caskdb
importRemove
self.assertTrue()
from a test, which was causing mypy to fail inmemory_store.py
Move
example.py
inside the package, so you can dopython -m caskdb.example
to run it.Add a
setup.cfg
and dummysetup.py
to make the package installable, moved dev dependencies tosetup.cfg
.A
pyproject.toml
would work too but it's the exact same setup in a bit more verbose toml format.Now
requirements_dev.txt
simply contains-e .[dev]
, which is equivalent to runningpip install -e .[dev]
as in:.
(current directory),-e
) package,dev
dependencies included.Editable installs mean when you change the code, the package reflects the change without needing to reinstall it.
Added a
mypy.ini
file to ignorevenv
andsetup.py
from raising typecheck issuesAdd
build
as the install tool, andtwine
as the tool to upload the wheels.To test these changes:
Create a venv
python3 -m venv venv
and activate itsource venv/bin/activate
Run
pip install -r requirements_dev.txt
Run
pytest
to ensure that we are indeed running tests on the packaged version ofcaskdb
. The tests will no longer pass without runningpip install
on our package now, becauseformat
,disk_store
etc. are no longer import-able directly without thecaskdb.
prefix.This is also why we chose the
src/
layout, because if we just put them in acaskdb/
folder, they would still be importable by the tests directly. That way the tests passing won't tell you if the package is correctly being installed or not.If tests pass, build the package by doing
python -m build
The upload the packages by creating an API key on PyPI, then running
twine upload ./dist/*
Once this is all done, you can
pip install caskdb
to install the package.Other than this, I think
pytype
is redundant in the dependencies,mypy
does the job fine, and also you might want to change the version of caskdb insetup.cfg
to1.0.0
if you wish.Resolves #5