Make script run on python 3.7

This commit is contained in:
Marty Oehme 2021-12-15 14:58:29 +01:00
parent 2a0312dfa2
commit abd48e0ee8
Signed by: Marty
GPG key ID: B7538B8F50A1C800
8 changed files with 62 additions and 13 deletions

View file

@ -7,6 +7,10 @@ and this project tries to adhere to [Semantic Versioning](https://semver.org/spe
## [Unreleased] ## [Unreleased]
### Changed
* Compatible with Python stretching back to version 3.7
## [0.4] - 2021-12-06 ## [0.4] - 2021-12-06
### Added ### Added

50
poetry.lock generated
View file

@ -30,6 +30,7 @@ python-versions = ">=3.6"
[package.dependencies] [package.dependencies]
colorama = {version = "*", markers = "platform_system == \"Windows\""} colorama = {version = "*", markers = "platform_system == \"Windows\""}
importlib-metadata = {version = "*", markers = "python_version < \"3.8\""}
[[package]] [[package]]
name = "colorama" name = "colorama"
@ -53,6 +54,21 @@ tomli = {version = "*", optional = true, markers = "extra == \"toml\""}
[package.extras] [package.extras]
toml = ["tomli"] toml = ["tomli"]
[[package]]
name = "importlib-metadata"
version = "0.23"
description = "Read metadata from Python packages"
category = "main"
optional = false
python-versions = ">=2.7,!=3.0,!=3.1,!=3.2,!=3.3"
[package.dependencies]
zipp = ">=0.5"
[package.extras]
docs = ["sphinx", "rst.linker"]
testing = ["packaging", "importlib-resources"]
[[package]] [[package]]
name = "iniconfig" name = "iniconfig"
version = "1.1.1" version = "1.1.1"
@ -80,6 +96,9 @@ category = "dev"
optional = false optional = false
python-versions = ">=3.6" python-versions = ">=3.6"
[package.dependencies]
importlib-metadata = {version = ">=0.12", markers = "python_version < \"3.8\""}
[package.extras] [package.extras]
dev = ["pre-commit", "tox"] dev = ["pre-commit", "tox"]
testing = ["pytest", "pytest-benchmark"] testing = ["pytest", "pytest-benchmark"]
@ -115,6 +134,7 @@ python-versions = ">=3.6"
atomicwrites = {version = ">=1.0", markers = "sys_platform == \"win32\""} atomicwrites = {version = ">=1.0", markers = "sys_platform == \"win32\""}
attrs = ">=19.2.0" attrs = ">=19.2.0"
colorama = {version = "*", markers = "sys_platform == \"win32\""} colorama = {version = "*", markers = "sys_platform == \"win32\""}
importlib-metadata = {version = ">=0.12", markers = "python_version < \"3.8\""}
iniconfig = "*" iniconfig = "*"
packaging = "*" packaging = "*"
pluggy = ">=0.12,<2.0" pluggy = ">=0.12,<2.0"
@ -163,16 +183,28 @@ python-versions = ">=2.6, !=3.0.*, !=3.1.*, !=3.2.*"
[[package]] [[package]]
name = "tomli" name = "tomli"
version = "1.2.2" version = "2.0.0"
description = "A lil' TOML parser" description = "A lil' TOML parser"
category = "dev" category = "dev"
optional = false optional = false
python-versions = ">=3.7"
[[package]]
name = "zipp"
version = "3.6.0"
description = "Backport of pathlib-compatible object wrapper for zip files"
category = "main"
optional = false
python-versions = ">=3.6" python-versions = ">=3.6"
[package.extras]
docs = ["sphinx", "jaraco.packaging (>=8.2)", "rst.linker (>=1.9)"]
testing = ["pytest (>=4.6)", "pytest-checkdocs (>=2.4)", "pytest-flake8", "pytest-cov", "pytest-enabler (>=1.0.1)", "jaraco.itertools", "func-timeout", "pytest-black (>=0.3.7)", "pytest-mypy"]
[metadata] [metadata]
lock-version = "1.1" lock-version = "1.1"
python-versions = "^3.9" python-versions = "^3.7"
content-hash = "3018d9e058177fcc4d085739d8dad7a04716ccf3a0e87a22e148960a146ca85b" content-hash = "fec236ab912efe582781c62e4cd2c4cd7e609557e284e067fa875f30ab806d93"
[metadata.files] [metadata.files]
atomicwrites = [ atomicwrites = [
@ -240,6 +272,10 @@ coverage = [
{file = "coverage-6.2-pp36.pp37.pp38-none-any.whl", hash = "sha256:5829192582c0ec8ca4a2532407bc14c2f338d9878a10442f5d03804a95fac9de"}, {file = "coverage-6.2-pp36.pp37.pp38-none-any.whl", hash = "sha256:5829192582c0ec8ca4a2532407bc14c2f338d9878a10442f5d03804a95fac9de"},
{file = "coverage-6.2.tar.gz", hash = "sha256:e2cad8093172b7d1595b4ad66f24270808658e11acf43a8f95b41276162eb5b8"}, {file = "coverage-6.2.tar.gz", hash = "sha256:e2cad8093172b7d1595b4ad66f24270808658e11acf43a8f95b41276162eb5b8"},
] ]
importlib-metadata = [
{file = "importlib_metadata-0.23-py2.py3-none-any.whl", hash = "sha256:d5f18a79777f3aa179c145737780282e27b508fc8fd688cb17c7a813e8bd39af"},
{file = "importlib_metadata-0.23.tar.gz", hash = "sha256:aa18d7378b00b40847790e7c27e11673d7fed219354109d0e7b9e5b25dc3ad26"},
]
iniconfig = [ iniconfig = [
{file = "iniconfig-1.1.1-py2.py3-none-any.whl", hash = "sha256:011e24c64b7f47f6ebd835bb12a743f2fbe9a26d4cecaa7f53bc4f35ee9da8b3"}, {file = "iniconfig-1.1.1-py2.py3-none-any.whl", hash = "sha256:011e24c64b7f47f6ebd835bb12a743f2fbe9a26d4cecaa7f53bc4f35ee9da8b3"},
{file = "iniconfig-1.1.1.tar.gz", hash = "sha256:bc3af051d7d14b2ee5ef9969666def0cd1a000e121eaea580d4a313df4b37f32"}, {file = "iniconfig-1.1.1.tar.gz", hash = "sha256:bc3af051d7d14b2ee5ef9969666def0cd1a000e121eaea580d4a313df4b37f32"},
@ -277,6 +313,10 @@ toml = [
{file = "toml-0.10.2.tar.gz", hash = "sha256:b3bda1d108d5dd99f4a20d24d9c348e91c4db7ab1b749200bded2f839ccbe68f"}, {file = "toml-0.10.2.tar.gz", hash = "sha256:b3bda1d108d5dd99f4a20d24d9c348e91c4db7ab1b749200bded2f839ccbe68f"},
] ]
tomli = [ tomli = [
{file = "tomli-1.2.2-py3-none-any.whl", hash = "sha256:f04066f68f5554911363063a30b108d2b5a5b1a010aa8b6132af78489fe3aade"}, {file = "tomli-2.0.0-py3-none-any.whl", hash = "sha256:b5bde28da1fed24b9bd1d4d2b8cba62300bfb4ec9a6187a957e8ddb9434c5224"},
{file = "tomli-1.2.2.tar.gz", hash = "sha256:c6ce0015eb38820eaf32b5db832dbc26deb3dd427bd5f6556cf0acac2c214fee"}, {file = "tomli-2.0.0.tar.gz", hash = "sha256:c292c34f58502a1eb2bbb9f5bbc9a5ebc37bee10ffb8c2d6bbdfa8eb13cc14e1"},
]
zipp = [
{file = "zipp-3.6.0-py3-none-any.whl", hash = "sha256:9fe5ea21568a0a70e50f273397638d39b03353731e6cbbb3fd8502a33fec40bc"},
{file = "zipp-3.6.0.tar.gz", hash = "sha256:71c644c5369f4a6e07636f0aa966270449561fcea2e3d6747b8d23efaa9d7832"},
] ]

View file

@ -8,13 +8,14 @@ packages = [
] ]
[tool.poetry.dependencies] [tool.poetry.dependencies]
importlib-metadata = {version = "^1.0", python = "<3.8"} importlib-metadata = {version = "^0.23", python = "<3.8"}
python = "^3.9" python = "^3.7"
click = "^8.0" click = "^8.0"
[tool.poetry.dev-dependencies] [tool.poetry.dev-dependencies]
pytest = "^6.2" pytest = "^6.2"
coverage = {extras = ["toml"], version = "^6.2"} coverage = {extras = ["toml"], version = "^6.2"}
pytest-cov = "^3.0.0" pytest-cov = "^3.0.0"
pytest-mock = "^3.6.1" pytest-mock = "^3.6.1"

View file

@ -1,9 +1,9 @@
# init.py # init.py
import sys import sys
if sys.version_info >= (3, 8): try:
from importlib.metadata import version as metadata_version from importlib.metadata import version as metadata_version
else: except ImportError:
from importlib_metadata import version as metadata_version from importlib_metadata import version as metadata_version
__version__ = str(metadata_version(__name__)) __version__ = str(metadata_version(__name__))

View file

@ -1,3 +1,5 @@
from __future__ import annotations
import sqlite3 import sqlite3
from habitmove.nomiedata import Tracker from habitmove.nomiedata import Tracker

View file

@ -1,3 +1,5 @@
from __future__ import annotations
from typing import Any, Union from typing import Any, Union
from dataclasses import dataclass, field from dataclasses import dataclass, field
import re import re

View file

@ -1,3 +1,5 @@
from __future__ import annotations
import sqlite3 import sqlite3
from typing import Optional from typing import Optional
from datetime import datetime from datetime import datetime

View file

@ -1,7 +1,7 @@
import sqlite3 import sqlite3
def create_database(name): def create_database(db_file: str) -> sqlite3.Connection:
"""create a database connection to the SQLite database """create a database connection to the SQLite database
specified by db_file specified by db_file
:param db_file: database file :param db_file: database file
@ -9,13 +9,11 @@ def create_database(name):
""" """
conn = None conn = None
try: try:
conn = sqlite3.connect(name) conn = sqlite3.connect(db_file)
return conn return conn
except sqlite3.Error as e: except sqlite3.Error as e:
print(e) print(e)
return conn
def create_tables(db): def create_tables(db):
c = db.cursor() c = db.cursor()