From 2c09c7f73e2fc770f42b5dd2588aa9634b4e7c6e Mon Sep 17 00:00:00 2001 From: Ben Sima Date: Wed, 10 Apr 2024 19:56:46 -0400 Subject: 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. --- Biz/Bild/Example.py | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) (limited to 'Biz/Bild/Example.py') 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__": -- cgit v1.2.3