From 4a292cc08d30d75b058a2d56443126248a55d002 Mon Sep 17 00:00:00 2001 From: Aminda Suomalainen Date: Thu, 18 May 2023 10:06:16 +0300 Subject: [PATCH] pre-commit: add mypy, black & pylint --- .pre-commit-config.yaml | 17 +++++++++++++++++ python/pin.py | 2 +- python/ssid-valid-len.py | 13 ++++++++++--- 3 files changed, 28 insertions(+), 4 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index dcf5715..e445c0f 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -24,13 +24,30 @@ repos: - id: doctoc # https://github.com/Mikaela/gist/blob/master/doctoc.txt args: [--update-only] + - repo: https://github.com/pre-commit/mirrors-mypy + rev: "v1.3.0" + hooks: + - id: mypy - repo: https://github.com/pre-commit/mirrors-prettier rev: "v3.0.0-alpha.9-for-vscode" hooks: - id: prettier + exclude_types: [python, pyi, jupyter] + - repo: https://github.com/psf/black + rev: 23.3.0 + hooks: + - id: black + #- id: black-jupyter - repo: https://github.com/editorconfig-checker/editorconfig-checker.python rev: "2.7.1" hooks: - id: editorconfig-checker alias: ec args: [-disable-max-line-length] + - repo: local + hooks: + - id: pylint + name: pylint + entry: pylint + language: system + types_or: [python, pyi] diff --git a/python/pin.py b/python/pin.py index 50d7adb..438fe41 100755 --- a/python/pin.py +++ b/python/pin.py @@ -9,7 +9,7 @@ except IndexError as noarg: try: for i in range(int(wantedCount)): - print(secrets.randbelow(10),end="") + print(secrets.randbelow(10), end="") except NameError as noWantedCount: print() print() diff --git a/python/ssid-valid-len.py b/python/ssid-valid-len.py index 5dd1330..4ed8065 100755 --- a/python/ssid-valid-len.py +++ b/python/ssid-valid-len.py @@ -1,17 +1,23 @@ #!/usr/bin/env python3 -''' +""" This script asks for a SSID name, counts it and tells whether it's of valid length -''' +""" # Request input or assume "test" on empty. -givenssid = str(input("Please enter the SSID you are thinking of (preferably 26 chars to fit _nomap): ") or "test") +givenssid = str( + input( + "Please enter the SSID you are thinking of (preferably 26 chars to fit _nomap): " + ) + or "test" +) # Ensure it's UTF-8 and store the size. E.g. åäö are longer than oao # TODO: make this a function too givenssidlen = len(givenssid.encode("utf8")) + # Checking the SSID length is done twice, so thus a function def checkssidlen(givenssidlen): # 32 bytes should be the maximum SSID length @@ -20,6 +26,7 @@ def checkssidlen(givenssidlen): else: print(givenssid, "is", givenssidlen, "to long, please select a different SSID") + # Checking the SSID without _nomap checkssidlen(givenssidlen) # TODO: make this a function too