-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
47 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
.idea | ||
.vscode | ||
__pycache__ | ||
.venv | ||
tmp* | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,19 @@ | ||
# Design Overview | ||
# Makefile | ||
|
||
`make all` or a specific target: | ||
```bash | ||
make venv | ||
make test | ||
make type-check | ||
make lint | ||
``` | ||
|
||
Run a specific test: | ||
```bash | ||
python -m unittest tests.test_stream.TestStream.test_distinct | ||
``` | ||
|
||
# Design principles | ||
|
||
## Fluent Interface Pattern | ||
The lib is built around a single entry point, the `Stream` class. This is the only import required. This lib must be trivial to use, all the behaviors it exposes should be carefully named and designed to make them as self-explanatory as possible. A stream declaration should resemble natural language: | ||
|
@@ -16,30 +31,3 @@ Each node in this composite structure exposes an `.accept` method enabling trave | |
|
||
## Decorator Pattern | ||
A `Stream[T]` both inherits from `Iterable[T]` and holds an `Iterable[T]` as its `.source`: when you instantiate a stream from an iterable you decorate it with a fluent interface. | ||
|
||
# Cheat Sheet: commands for contributors | ||
|
||
```bash | ||
git clone [email protected]:ebonnal/streamable | ||
cd streamable | ||
python -m venv .venv | ||
source .venv/bin/activate | ||
python -m pip install -r requirements-dev.txt | ||
``` | ||
|
||
## run unittest and check coverage | ||
```bash | ||
python -m coverage run -m unittest && coverage report | ||
``` | ||
|
||
## check typing | ||
```bash | ||
python -m mypy streamable tests | ||
``` | ||
|
||
## lint | ||
```bash | ||
python -m autoflake --in-place --remove-all-unused-imports --remove-unused-variables --ignore-init-module -r streamable tests \ | ||
&& python -m isort streamable tests \ | ||
&& python -m black . | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
VENV_DIR := .venv | ||
|
||
all: venv test type-check lint | ||
|
||
help: | ||
@echo "Available commands:" | ||
@echo " make all - Run all tasks: venv, test, type-check, lint" | ||
@echo " make venv - Create a virtual environment and install dependencies" | ||
@echo " make test - Run unittests and check coverage" | ||
@echo " make type-check - Check typing with mypy" | ||
@echo " make lint - Lint the codebase" | ||
@echo " make clean - Clean up the environment" | ||
|
||
venv: | ||
python3 -m venv $(VENV_DIR) | ||
$(VENV_DIR)/bin/pip install -r requirements-dev.txt | ||
|
||
test: | ||
$(VENV_DIR)/bin/python -m coverage run -m unittest --failfast | ||
$(VENV_DIR)/bin/coverage html | ||
|
||
type-check: | ||
$(VENV_DIR)/bin/python -m mypy --install-types --non-interactive streamable tests | ||
|
||
lint: | ||
$(VENV_DIR)/bin/python -m autoflake --in-place --remove-all-unused-imports --remove-unused-variables --ignore-init-module -r streamable tests | ||
$(VENV_DIR)/bin/python -m isort streamable tests | ||
$(VENV_DIR)/bin/python -m black . |