Skip to content
This repository has been archived by the owner on Jan 5, 2024. It is now read-only.

Commit

Permalink
Fixes #57 runs black & isort for code formatting
Browse files Browse the repository at this point in the history
To have latest black, we need updated typed-ast,
for that we have to upgrade mypy too, and for mypy
upgrade to work, we had to upgrade the mypy-extensions.

It first runs isort to check if it passes, and then
it runs black. Both uses 100 as line length.

setup.py marks Python version as >= 3.7 as we are testing
and running the code only on 3.7 on Debian Buster.

Also contains the formatting change in proxy.py for black
check to run sucessfully on CI.
  • Loading branch information
kushaldas committed Jun 4, 2020
1 parent ffa4cb3 commit f9bcbd3
Show file tree
Hide file tree
Showing 7 changed files with 162 additions and 73 deletions.
9 changes: 8 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,20 @@ safety: ## Runs `safety check` to check python dependencies for vulnerabilities
done

.PHONY: lint
lint: ## Run flake8
lint: isort black ## Run isort, black and flake8
@flake8 securedrop_proxy tests

.PHONY: mypy
mypy: ## Run mypy static type checker
@mypy --ignore-missing-imports securedrop_proxy

.PHONY: black
black: ## Run black for file formatting
@black --config ./blackconfig/pyproject.toml --check securedrop_proxy tests

.PHONY: isort
isort: ## Run isort for file formatting
@isort -c -w 100 securedrop_proxy/*.py tests/*.py --diff

.PHONY: update-pip-requirements
update-pip-requirements: ## Updates all Python requirements files via pip-compile.
Expand Down
2 changes: 2 additions & 0 deletions blackconfig/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[tool.black]
line-length = 100
8 changes: 5 additions & 3 deletions dev-requirements.in
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
black==19.10b0
coverage==5.0
flake8==3.6.0
isort==4.3.21
mccabe==0.6.1
multidict==4.4.2
mypy==0.701
mypy-extensions==0.4.1
pip-tools==3.1.0
mypy==0.761
mypy-extensions==0.4.3
pip-tools==4.3.0
pycodestyle==2.4.0
pyflakes==2.0.0
six==1.11.0
Expand Down
205 changes: 143 additions & 62 deletions dev-requirements.txt

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions securedrop_proxy/entrypoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@

def start() -> None:
"""
Set up a new proxy object with an error handler, configuration that we read from argv[1], and
the original user request from STDIN.
Set up a new proxy object with an error handler, configuration that we read
from argv[1], and the original user request from STDIN.
"""
try:
configure_logging()
Expand Down
5 changes: 1 addition & 4 deletions securedrop_proxy/proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,7 @@ def __init__(self, status: int) -> None:


class Proxy:
def __init__(
self, conf_path: str, req: Req = Req(), timeout: float = 120.0
) -> None:
# The configuration path for Proxy is a must.
def __init__(self, conf_path: str, req: Req = Req(), timeout: float = 10.0) -> None:
self.read_conf(conf_path)

self.req = req
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
long_description_content_type="text/markdown",
license="GPLv3+",
install_requires=["requests", "furl", "pyyaml", "werkzeug"],
python_requires=">=3.5",
python_requires=">=3.7",
url="https://github.com/freedomofpress/securedrop-proxy",
packages=setuptools.find_packages(exclude=["docs", "tests"]),
package_data={
Expand Down

0 comments on commit f9bcbd3

Please sign in to comment.