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
[tool.poetry] | |
name = "my_package" | |
version = "0.13.2" | |
[[tool.poetry.source]] | |
name = "custom-1" | |
url = "some-url-to-gitlab-private-registry" | |
priority = "default" | |
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
#!/usr/bin/env python | |
import sys | |
print(sys.argv[1]) |
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
# where the tkutcher repository is cloned ("installed") to | |
export TK_LIB_DIR="${HOME}/tk/lib/tkutcher" | |
# sourcing rc files relevant for this machine | |
source "${TK_LIB_DIR}/rc/aliases.sh" | |
source "${TK_LIB_DIR}/rc/env.sh" | |
source "${TK_LIB_DIR}/rc/funs.sh" | |
source "${TK_LIB_DIR}/rc/p10k.zsh" |
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
# set up basic variables for where things are located | |
DEVTOOLS_VENV_DIR="${HOME}/tk/lib/devtools/venv" | |
# activate the virtual environment with the dependencies | |
source "${DEVTOOLS_VENV_DIR}/bin/activate" | |
# invoke nvl inside that virtual environment and forward args | |
nvl "$@" |
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
def test_writes_config_properly(tmpdir): | |
dest_path = pathlib.Path(tmpdir) / "example-output.json" | |
assert not dest_path.exists() | |
config = MyConfig(x="4", y="18") | |
write_to_file(config, dest) | |
assert dest_path.exists() | |
assert read_from_file(dest_path).x == "4" |
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
@pytest.fixture() | |
def res_dir(): | |
return pathlib.Path(__file__).parent / "res" |
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
def test_read_from_file_1(): | |
c = read_from_file(pathlib.Path(__file__).parent / "res" / "example-config-001.json") | |
assert c.x == "3" | |
def test_read_from_file_2(): | |
c = read_from_file(pathlib.Path(__file__).parent / "res" / "example-config-002.json") | |
assert c.x == "18" |
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
def read_from_file(src_path="my-config.json") -> MyConfig: | |
with open(src_path, "r") as f: | |
d = json.load(f) | |
return MyConfig(d["x"], d["y"]) | |
def write_to_file(c: MyConfig, dest_path="my-config.json") -> None: | |
with open(dest_path, "w") as f: | |
f.write({"x": c.x, "y": c.y}) |
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
@dataclasses.dataclass | |
class MyConfig: | |
x: str | |
y: str | |
def read_from_file() -> MyConfig: | |
with open("my-config.json", "r") as f: | |
d = json.load(f) | |
return MyConfig(d["x"], d["y"]) |
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
""" | |
buffered_iterator - Decorates an iterator with "has_next" by buffering values. | |
Example use case for this is if you have a base interface/ABC that has methods | |
`has_next` and `get_next`, and several classes realizing this interface already | |
would have iterators internally, you wouldn't want them to each have to | |
implement the logic for `has_next` - so it would be better to decorate an | |
iterator with some sort of `has_next`. | |
Inspiration from |
NewerOlder