diff --git a/.flake8 b/.flake8 new file mode 100644 index 0000000..c4838d9 --- /dev/null +++ b/.flake8 @@ -0,0 +1,8 @@ +[flake8] +select = ANN,B,B9,BLK,C,D,DAR,E,F,I,S,W +ignore = E203,W503,ANN101,ANN102 +per-file-ignores = tests/*:S101 +max-line-length = 88 +application-import-names = vidgen,tests +import-order-style = google +docstring-convention = google diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..491b1a1 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,4 @@ +{ + "python.linting.enabled": true, + "python.linting.flake8Enabled": true +} \ No newline at end of file diff --git a/poetry.lock b/poetry.lock index 4ebbbfe..a1c0875 100644 --- a/poetry.lock +++ b/poetry.lock @@ -371,7 +371,7 @@ secure = ["certifi", "cryptography (>=1.3.4)", "idna (>=2.0.0)", "pyOpenSSL (>=0 socks = ["PySocks (>=1.5.6,<1.5.7 || >1.5.7,<2.0)"] [metadata] -content-hash = "026e038e920e232b777a5cdce90826fd4d514746ef70d4bcdb9b51029059020c" +content-hash = "79080e433cd4f13b656467565b30525d1cd82155f5ad6a3fcf5895c7dd3a44a8" python-versions = "^3.8" [metadata.files] diff --git a/src/replit/__init__.py b/src/replit/__init__.py new file mode 100644 index 0000000..204c15f --- /dev/null +++ b/src/replit/__init__.py @@ -0,0 +1,2 @@ +"""The replit python module.""" +from .database import db diff --git a/src/replit/__pycache__/__init__.cpython-38.pyc b/src/replit/__pycache__/__init__.cpython-38.pyc new file mode 100644 index 0000000..03dc7f8 Binary files /dev/null and b/src/replit/__pycache__/__init__.cpython-38.pyc differ diff --git a/src/db/db.py b/src/replit/database/__init__.py similarity index 95% rename from src/db/db.py rename to src/replit/database/__init__.py index 88fbafa..849fa99 100644 --- a/src/db/db.py +++ b/src/replit/database/__init__.py @@ -1,4 +1,5 @@ """Interface with the Replit Database.""" +import os import json from sys import stderr from typing import Any, Callable, Dict, Tuple, Union @@ -12,7 +13,8 @@ JSON_TYPE = Union[str, int, float, bool, type(None), dict, list] class JSONKey: """Represents a key in the database that holds a JSON value. - db.jsonkey() will initialize an instance for you, you don't have to do it manually.""" + db.jsonkey() will initialize an instance for you, + you don't have to do it manually.""" def __init__( self, @@ -36,7 +38,10 @@ class JSONKey: return self.dtype is Any or isinstance(data, self.dtype) def _type_mismatch_msg(self, data: Any) -> str: - return f"Type mismatch: Got type {type(data).__name__}, expected {self.dtype.__name__}" + return ( + f"Type mismatch: Got type {type(data).__name__}," + "expected {self.dtype.__name__}" + ) def get(self): """Get the value of the key. @@ -87,7 +92,8 @@ class JSONKey: """Prompt user for action when key is invalid.""" while True: choice = input( - "d to use default, v to view the invalid data, c to insert custom value, ^C to exit: " + "d to use default, v to view the invalid data, c to insert custom value," + "^C to exit: " ) if choice.startswith("d"): print("Writing default...") @@ -232,3 +238,6 @@ class ReplitDb(dict): def __repr__(self) -> str: """A representation of the database.""" return f"" + + +db = ReplitDb(os.environ["REPLIT_DB_URL"]) diff --git a/src/replit/database/__pycache__/__init__.cpython-38.pyc b/src/replit/database/__pycache__/__init__.cpython-38.pyc new file mode 100644 index 0000000..0107f80 Binary files /dev/null and b/src/replit/database/__pycache__/__init__.cpython-38.pyc differ