Skip to content

Commit

Permalink
A few ergonomic fixes (#191)
Browse files Browse the repository at this point in the history
What:
- Rename `naz.nazcodec.BaseNazCodec` to `naz.codec.BaseCodec`
- Rename `naz.Client.codec_class` to `naz.Client.codec`  
- Add ability for `naz.log.SimpleLogger` to render logs as a python dictionary
- run `mypy` and `pytype` in `benchmarks/` and `examples/` directory

Why:
- Better ergonomics
- Better debugging
  • Loading branch information
komuw authored Dec 5, 2019
1 parent c47f503 commit cc6ce64
Show file tree
Hide file tree
Showing 58 changed files with 1,378 additions and 630 deletions.
10 changes: 8 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,20 @@ jobs:
- name: run them analyzers
run: |
printf "\n\t running black:\n"
black --line-length=100 --check . || { printf "\\n\\t please use black to format your code."; exit 77; }
printf "\n\t running flake8:\n"
flake8 .
printf "\n\t running pylint:\n"
pylint --enable=E --disable=W,R,C naz/ tests/ cli/ documentation/ examples/ benchmarks/
printf "\n\t running bandit:\n"
bandit -r --exclude .venv -ll .
# to find types, use reveal_type eg: reveal_type(asyncio.get_event_loop())
# see: http://mypy.readthedocs.io/en/latest/common_issues.html#displaying-the-type-of-an-expression
mypy --show-column-numbers --ignore-missing-imports -p cli -p naz #--strict
pytype --verbosity 0 --python-version 3.7 --protocols --strict-import --keep-going naz/ cli/
printf "\n\t running mypy:\n"
mypy --show-column-numbers --ignore-missing-imports cli/ naz/ tests/ examples/ benchmarks/ #--strict
printf "\n\t running pytype:\n"
pytype --verbosity 0 --python-version 3.7 --protocols --strict-import --keep-going naz/ cli/ examples/ benchmarks/
env:
PYTHONASYNCIODEBUG: '1'
NAZ_DEBUG: 'NAZ_DEBUG'
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@
most recent version is listed first.


## **version:** v0.7.5
- Rename `naz.nazcodec.BaseNazCodec` to `naz.codec.BaseCodec`: https://github.com/komuw/naz/pull/191
- Rename `naz.Client.codec_class` to `naz.Client.codec`: https://github.com/komuw/naz/pull/191
- Add ability for `naz.log.SimpleLogger` to render logs as a python dictionary: https://github.com/komuw/naz/pull/191


## **version:** v0.7.4
- Fix a bug that prevented `enquire_link` and `deliver_sm` from been sent: https://github.com/komuw/naz/pull/179
- Enforce `naz` message protocol in code: https://github.com/komuw/naz/pull/179
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ test:
@printf "\n run flake8::\n" && flake8 .
@printf "\n run pylint::\n" && pylint --enable=E --disable=W,R,C naz/ tests/ cli/ documentation/ examples/ benchmarks/
@printf "\n run bandit::\n" && bandit -r --exclude .venv -ll .
@printf "\n run mypy::\n" && mypy --show-column-numbers --ignore-missing-imports -p cli -p naz
@printf "\n run pytype::\n" && pytype --verbosity 0 --python-version 3.7 --protocols --strict-import --keep-going naz/ cli/
@printf "\n run mypy::\n" && mypy --show-column-numbers --ignore-missing-imports cli/ naz/ tests/ examples/ benchmarks/
@printf "\n run pytype::\n" && pytype --verbosity 0 --python-version 3.7 --protocols --strict-import --keep-going naz/ cli/ examples/ benchmarks/

# note `.nojekyll` file is important inside `docs/` folder
# without it, css styling for docs in https://komuw.github.io/naz/ is broken
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ FROM python:3.7
ARG NAZ_BRANCH=master

WORKDIR /usr/src/app
COPY ./ /usr/src/app
COPY . /usr/src/app

ENV PYTHONPATH="/usr/src/app"

Expand Down
8 changes: 4 additions & 4 deletions benchmarks/smpp_n_broker_servers.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ def __init__(
log_metadata={"container_name": self.container_name, "chaos": self.chaos},
)

self.container_max_run_duration: float = 16.00 # mins
self.container_min_run_duration: float = 13.00 # mins
self.container_max_run_duration: int = 16 # mins
self.container_min_run_duration: int = 13 # mins

self.container_max_stop_duration: float = 3.00 # mins
self.container_min_stop_duration: float = 1.00 # mins
self.container_max_stop_duration: int = 3 # mins
self.container_min_stop_duration: int = 1 # mins

def start(self):
self.stop()
Expand Down
8 changes: 4 additions & 4 deletions docs/_modules/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

<meta name="viewport" content="width=device-width, initial-scale=1.0">

<title>Overview: module code &mdash; naz v0.7.4 documentation</title>
<title>Overview: module code &mdash; naz v0.7.5 documentation</title>



Expand Down Expand Up @@ -60,7 +60,7 @@


<div class="version">
v0.7.4
v0.7.5
</div>


Expand Down Expand Up @@ -93,7 +93,7 @@
<li class="toctree-l1"><a class="reference internal" href="../protocol.html">protocol</a></li>
<li class="toctree-l1"><a class="reference internal" href="../correlater.html">correlater</a></li>
<li class="toctree-l1"><a class="reference internal" href="../hooks.html">hooks</a></li>
<li class="toctree-l1"><a class="reference internal" href="../nazcodec.html">nazcodec</a></li>
<li class="toctree-l1"><a class="reference internal" href="../codec.html">codec</a></li>
<li class="toctree-l1"><a class="reference internal" href="../broker.html">broker</a></li>
<li class="toctree-l1"><a class="reference internal" href="../ratelimiter.html">ratelimiter</a></li>
<li class="toctree-l1"><a class="reference internal" href="../sequence.html">sequence</a></li>
Expand Down Expand Up @@ -163,10 +163,10 @@
<h1>All modules for which code is available</h1>
<ul><li><a href="naz/broker.html">naz.broker</a></li>
<li><a href="naz/client.html">naz.client</a></li>
<li><a href="naz/codec.html">naz.codec</a></li>
<li><a href="naz/correlater.html">naz.correlater</a></li>
<li><a href="naz/hooks.html">naz.hooks</a></li>
<li><a href="naz/log.html">naz.log</a></li>
<li><a href="naz/nazcodec.html">naz.nazcodec</a></li>
<li><a href="naz/protocol.html">naz.protocol</a></li>
<li><a href="naz/ratelimiter.html">naz.ratelimiter</a></li>
<li><a href="naz/sequence.html">naz.sequence</a></li>
Expand Down
6 changes: 3 additions & 3 deletions docs/_modules/naz/broker.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

<meta name="viewport" content="width=device-width, initial-scale=1.0">

<title>naz.broker &mdash; naz v0.7.4 documentation</title>
<title>naz.broker &mdash; naz v0.7.5 documentation</title>



Expand Down Expand Up @@ -60,7 +60,7 @@


<div class="version">
v0.7.4
v0.7.5
</div>


Expand Down Expand Up @@ -93,7 +93,7 @@
<li class="toctree-l1"><a class="reference internal" href="../../protocol.html">protocol</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../correlater.html">correlater</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../hooks.html">hooks</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../nazcodec.html">nazcodec</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../codec.html">codec</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../broker.html">broker</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../ratelimiter.html">ratelimiter</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../sequence.html">sequence</a></li>
Expand Down
Loading

0 comments on commit cc6ce64

Please sign in to comment.