diff options
author | Ben Sima <ben@bsima.me> | 2024-04-10 19:56:46 -0400 |
---|---|---|
committer | Ben Sima <ben@bsima.me> | 2024-04-10 19:56:46 -0400 |
commit | 2c09c7f73e2fc770f42b5dd2588aa9634b4e7c6e (patch) | |
tree | a6c49dddb7b1735a0f8de2a9a5f4efb605f16f36 /Biz/Bild | |
parent | 051973aba8953ebde51eb1436fb3994e7ae699dc (diff) |
Switch from black to ruff format
Ruff is faster and if it supports everything that black supports than why not? I
did have to pull in a more recent version from unstable, but that's easy to do
now. And I decided to just go ahead and configure ruff by turning on almost all
checks, which meant I had to fix a whole bunch of things, but I did that and
everything is okay now.
Diffstat (limited to 'Biz/Bild')
-rw-r--r-- | Biz/Bild/Builder.nix | 22 | ||||
-rw-r--r-- | Biz/Bild/Example.py | 22 |
2 files changed, 27 insertions, 17 deletions
diff --git a/Biz/Bild/Builder.nix b/Biz/Bild/Builder.nix index d2e6875..4bef830 100644 --- a/Biz/Bild/Builder.nix +++ b/Biz/Bild/Builder.nix @@ -110,14 +110,14 @@ let inherit name src CODEROOT; propagatedBuildInputs = langdeps_ ++ sysdeps_; buildInputs = sysdeps_; - nativeCheckInputs = [ black mypy ruff ]; + nativeCheckInputs = lib.attrsets.attrVals [ "mypy" "ruff" ] bild.pkgs; checkPhase = '' check() { $@ || { echo "fail: $name: $3"; exit 1; } } cp ${../../pyproject.toml} ./pyproject.toml - check python -m black --quiet --exclude 'setup\.py$' --check . - check ${ruff}/bin/ruff check . + check ruff format --exclude 'setup.py' --check . + check ruff check --exclude 'setup.py' --exclude '__init__.py' . touch ./py.typed check python -m mypy \ --explicit-package-bases \ @@ -133,15 +133,15 @@ let find . -type d -exec touch {}/__init__.py \; # generate a minimal setup.py cat > setup.py << EOF - from setuptools import setup, find_packages + from setuptools import find_packages, setup setup( - name='${name}', - entry_points={'console_scripts':['${name} = ${mainModule}:main']}, - version='0.0.0', - url='git://simatime.com/biz.git', - author='dev', - author_email='dev@simatime.com', - description='nil', + name="${name}", + entry_points={"console_scripts":["${name} = ${mainModule}:main"]}, + version="0.0.0", + url="git://simatime.com/biz.git", + author="dev", + author_email="dev@simatime.com", + description="nil", packages=find_packages(), install_requires=[], ) diff --git a/Biz/Bild/Example.py b/Biz/Bild/Example.py index 5d165d8..1bd30ae 100644 --- a/Biz/Bild/Example.py +++ b/Biz/Bild/Example.py @@ -1,32 +1,42 @@ """ +Test that bild can build Python stuff. + Example Python file that also serves as a test case for bild. """ + # : out example # : dep cryptography import sys + import cryptography.fernet def cryptic_hello(name: str) -> str: - "Example taken from `cryptography` docs." + """ + Encrypt and decrypt `name`. + + Example taken from `cryptography` docs. + """ key = cryptography.fernet.Fernet.generate_key() f = cryptography.fernet.Fernet(key) token = f.encrypt(hello(name).encode("utf-8")) ret = f.decrypt(token).decode("utf-8") - assert ret == hello(name) + if ret != hello(name): + msg = "en/decryption failed!" + raise ValueError(msg) return ret def hello(name: str) -> str: - "Say hello" + """Say hello.""" return f"Hello {name}" def main() -> None: - "Entrypoint" + """Entrypoint.""" if "test" in sys.argv: - print("testing success") - print(cryptic_hello("world")) + sys.stdout.write("testing success") + sys.stdout.write(cryptic_hello("world")) if __name__ == "__main__": |