Move existing linting into flakeheaven (#1628)

* add black and isort to flakeheaven

* update lock file

* clean up poe config

* run formta on python blocks in markdown file

* disable code for black being confused about markdown

* add cache timeout for flakeheaven

See: https://github.com/flakeheaven/flakeheaven/issues/71
This commit is contained in:
Jonathan Wren 2022-10-31 09:31:17 -07:00 committed by GitHub
parent 9150f07984
commit 51e9ce5638
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 62 additions and 40 deletions

View file

@ -100,12 +100,12 @@ something like `pip3 install crytography`)
import base64
import getpass
from pathlib import Path
from cryptography.fernet import Fernet
from cryptography.hazmat.backends import default_backend
from cryptography.hazmat.primitives import hashes
from cryptography.hazmat.primitives.kdf.pbkdf2 import PBKDF2HMAC
filepath = input("journal file path: ")
password = getpass.getpass("Password: ")
@ -123,7 +123,7 @@ kdf = PBKDF2HMAC(
key = base64.urlsafe_b64encode(kdf.derive(password))
print(Fernet(key).decrypt(ciphertext).decode('utf-8'))
print(Fernet(key).decrypt(ciphertext).decode("utf-8"))
```
**Example for jrnl v1 files**:
@ -137,18 +137,19 @@ like `pip3 install pycrypto`)
"""
import argparse
from Crypto.Cipher import AES
import getpass
import hashlib
from Crypto.Cipher import AES
parser = argparse.ArgumentParser()
parser.add_argument("filepath", help="journal file to decrypt")
args = parser.parse_args()
pwd = getpass.getpass()
key = hashlib.sha256(pwd.encode('utf-8')).digest()
key = hashlib.sha256(pwd.encode("utf-8")).digest()
with open(args.filepath, 'rb') as f:
with open(args.filepath, "rb") as f:
ciphertext = f.read()
crypto = AES.new(key, AES.MODE_CBC, ciphertext[:16])

38
poetry.lock generated
View file

@ -229,6 +229,34 @@ mccabe = ">=0.6.0,<0.7.0"
pycodestyle = ">=2.8.0,<2.9.0"
pyflakes = ">=2.4.0,<2.5.0"
[[package]]
name = "flake8-black"
version = "0.3.3"
description = "flake8 plugin to call black as a code style validator"
category = "dev"
optional = false
python-versions = ">=3.7"
[package.dependencies]
black = ">=22.1.0"
flake8 = ">=3.0.0"
tomli = "*"
[[package]]
name = "flake8-isort"
version = "5.0.0"
description = "flake8 plugin that integrates isort ."
category = "dev"
optional = false
python-versions = ">=3.7"
[package.dependencies]
flake8 = "*"
isort = ">=4.3.5,<6"
[package.extras]
test = ["pytest"]
[[package]]
name = "flakeheaven"
version = "3.2.0"
@ -1130,7 +1158,7 @@ testing = ["func-timeout", "jaraco.itertools", "pytest (>=6)", "pytest-black (>=
[metadata]
lock-version = "1.1"
python-versions = ">=3.10.0, <3.13"
content-hash = "e2a31438b3c6fbf90093531b3f877818d8dbf85e2c4f95e879888a3aa66a4ee3"
content-hash = "13e2102b7ddeb9ac4f1f2fddcfa6275d565c3eec9fa8da1b4657a02e20f900c9"
[metadata.files]
ansiwrap = [
@ -1319,6 +1347,14 @@ flake8 = [
{file = "flake8-4.0.1-py2.py3-none-any.whl", hash = "sha256:479b1304f72536a55948cb40a32dce8bb0ffe3501e26eaf292c7e60eb5e0428d"},
{file = "flake8-4.0.1.tar.gz", hash = "sha256:806e034dda44114815e23c16ef92f95c91e4c71100ff52813adf7132a6ad870d"},
]
flake8-black = [
{file = "flake8-black-0.3.3.tar.gz", hash = "sha256:8211f5e20e954cb57c709acccf2f3281ce27016d4c4b989c3e51f878bb7ce12a"},
{file = "flake8_black-0.3.3-py3-none-any.whl", hash = "sha256:7d667d0059fd1aa468de1669d77cc934b7f1feeac258d57bdae69a8e73c4cd90"},
]
flake8-isort = [
{file = "flake8-isort-5.0.0.tar.gz", hash = "sha256:e336f928c7edc509684930ab124414194b7f4e237c712af8fcbdf49d8747b10c"},
{file = "flake8_isort-5.0.0-py3-none-any.whl", hash = "sha256:c73f9cbd1bf209887f602a27b827164ccfeba1676801b2aa23cb49051a1be79c"},
]
flakeheaven = [
{file = "flakeheaven-3.2.0-py3-none-any.whl", hash = "sha256:ec5a508c3db64d73128b65cb2a5a2c0a2d9f2e4b435e9fa2bcc03bf0df86da79"},
{file = "flakeheaven-3.2.0.tar.gz", hash = "sha256:225333d7bf309079f19a2c5f02d427fc7558a0d0c065944de88041ca94f5525c"},

View file

@ -45,6 +45,8 @@ tzlocal = ">=4.0" # https://github.com/regebro/tzlocal/blob/master/CHANGES.txt
[tool.poetry.dev-dependencies]
black = { version = ">=21.5b2", allow-prereleases = true }
flakeheaven = ">=3.0"
flake8-black = ">=0.3.3"
flake8-isort = ">=5.0.0"
ipdb = "*"
isort = ">=5.10"
mkdocs = ">=1.0,<1.3"
@ -62,26 +64,6 @@ xmltodict = "*"
jrnl = 'jrnl.cli:cli'
[tool.poe.tasks]
format-run = [
{cmd = "black ."},
]
format-check = [
{cmd = "black --version"},
{cmd = "black --check --diff ."},
]
style-check = [
{cmd = "flakeheaven --version"},
{cmd = "flakeheaven plugins"},
{cmd = "flakeheaven lint"},
]
sort-run = [
{cmd = "isort ."},
]
sort-check = [
{cmd = "isort --version"},
{cmd = "isort --check ."},
]
docs-check.default_item_type = "script"
docs-check.sequence = [
"tasks:delete_files(['sitemap.xml', 'config.json'])",
@ -100,22 +82,23 @@ test-run = [
{cmd = "tox -q -e py --"},
]
installer-check = [
{cmd = "poetry --version"},
{cmd = "poetry check"},
# Groups of tasks
format.default_item_type = "cmd"
format.sequence = [
"isort .",
"black .",
]
# Groups of tasks
format = [
"format-run",
"sort-run",
]
lint = [
"installer-check",
"style-check",
"sort-check",
"format-check",
lint.env = { FLAKEHEAVEN_CACHE_TIMEOUT = "0" }
lint.default_item_type = "cmd"
lint.sequence = [
"poetry --version",
"poetry check",
"flakeheaven --version",
"flakeheaven plugins",
"flakeheaven lint",
]
test = [
"lint",
"test-run",
@ -169,6 +152,8 @@ pycodestyle = [
"-E70",
"-W1*", "-W2*", "-W3*", "-W5*",
]
"flake8-*" = ["+*"]
flake8-black = ["-BLK901"]
[build-system]