From abd48e0ee817fd558211be72e89389d69e3198d6 Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Wed, 15 Dec 2021 14:58:29 +0100 Subject: [PATCH] Make script run on python 3.7 --- CHANGELOG.md | 4 +++ poetry.lock | 50 ++++++++++++++++++++++++++++++++---- pyproject.toml | 5 ++-- src/habitmove/__init__.py | 4 +-- src/habitmove/habits.py | 2 ++ src/habitmove/nomiedata.py | 2 ++ src/habitmove/repetitions.py | 2 ++ src/habitmove/schema.py | 6 ++--- 8 files changed, 62 insertions(+), 13 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5c5441f..7adcaa9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ and this project tries to adhere to [Semantic Versioning](https://semver.org/spe ## [Unreleased] +### Changed + +* Compatible with Python stretching back to version 3.7 + ## [0.4] - 2021-12-06 ### Added diff --git a/poetry.lock b/poetry.lock index e446fb1..f5775b8 100644 --- a/poetry.lock +++ b/poetry.lock @@ -30,6 +30,7 @@ python-versions = ">=3.6" [package.dependencies] colorama = {version = "*", markers = "platform_system == \"Windows\""} +importlib-metadata = {version = "*", markers = "python_version < \"3.8\""} [[package]] name = "colorama" @@ -53,6 +54,21 @@ tomli = {version = "*", optional = true, markers = "extra == \"toml\""} [package.extras] 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]] name = "iniconfig" version = "1.1.1" @@ -80,6 +96,9 @@ category = "dev" optional = false python-versions = ">=3.6" +[package.dependencies] +importlib-metadata = {version = ">=0.12", markers = "python_version < \"3.8\""} + [package.extras] dev = ["pre-commit", "tox"] testing = ["pytest", "pytest-benchmark"] @@ -115,6 +134,7 @@ python-versions = ">=3.6" atomicwrites = {version = ">=1.0", markers = "sys_platform == \"win32\""} attrs = ">=19.2.0" colorama = {version = "*", markers = "sys_platform == \"win32\""} +importlib-metadata = {version = ">=0.12", markers = "python_version < \"3.8\""} iniconfig = "*" packaging = "*" pluggy = ">=0.12,<2.0" @@ -163,16 +183,28 @@ python-versions = ">=2.6, !=3.0.*, !=3.1.*, !=3.2.*" [[package]] name = "tomli" -version = "1.2.2" +version = "2.0.0" description = "A lil' TOML parser" category = "dev" 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" +[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] lock-version = "1.1" -python-versions = "^3.9" -content-hash = "3018d9e058177fcc4d085739d8dad7a04716ccf3a0e87a22e148960a146ca85b" +python-versions = "^3.7" +content-hash = "fec236ab912efe582781c62e4cd2c4cd7e609557e284e067fa875f30ab806d93" [metadata.files] atomicwrites = [ @@ -240,6 +272,10 @@ coverage = [ {file = "coverage-6.2-pp36.pp37.pp38-none-any.whl", hash = "sha256:5829192582c0ec8ca4a2532407bc14c2f338d9878a10442f5d03804a95fac9de"}, {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 = [ {file = "iniconfig-1.1.1-py2.py3-none-any.whl", hash = "sha256:011e24c64b7f47f6ebd835bb12a743f2fbe9a26d4cecaa7f53bc4f35ee9da8b3"}, {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"}, ] tomli = [ - {file = "tomli-1.2.2-py3-none-any.whl", hash = "sha256:f04066f68f5554911363063a30b108d2b5a5b1a010aa8b6132af78489fe3aade"}, - {file = "tomli-1.2.2.tar.gz", hash = "sha256:c6ce0015eb38820eaf32b5db832dbc26deb3dd427bd5f6556cf0acac2c214fee"}, + {file = "tomli-2.0.0-py3-none-any.whl", hash = "sha256:b5bde28da1fed24b9bd1d4d2b8cba62300bfb4ec9a6187a957e8ddb9434c5224"}, + {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"}, ] diff --git a/pyproject.toml b/pyproject.toml index fa14e83..914b0dd 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -8,13 +8,14 @@ packages = [ ] [tool.poetry.dependencies] -importlib-metadata = {version = "^1.0", python = "<3.8"} -python = "^3.9" +importlib-metadata = {version = "^0.23", python = "<3.8"} +python = "^3.7" click = "^8.0" [tool.poetry.dev-dependencies] pytest = "^6.2" coverage = {extras = ["toml"], version = "^6.2"} + pytest-cov = "^3.0.0" pytest-mock = "^3.6.1" diff --git a/src/habitmove/__init__.py b/src/habitmove/__init__.py index 4ed1b57..fcbc880 100644 --- a/src/habitmove/__init__.py +++ b/src/habitmove/__init__.py @@ -1,9 +1,9 @@ # init.py import sys -if sys.version_info >= (3, 8): +try: from importlib.metadata import version as metadata_version -else: +except ImportError: from importlib_metadata import version as metadata_version __version__ = str(metadata_version(__name__)) diff --git a/src/habitmove/habits.py b/src/habitmove/habits.py index 0866380..a6d6f96 100644 --- a/src/habitmove/habits.py +++ b/src/habitmove/habits.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import sqlite3 from habitmove.nomiedata import Tracker diff --git a/src/habitmove/nomiedata.py b/src/habitmove/nomiedata.py index 9deab64..75a4189 100644 --- a/src/habitmove/nomiedata.py +++ b/src/habitmove/nomiedata.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from typing import Any, Union from dataclasses import dataclass, field import re diff --git a/src/habitmove/repetitions.py b/src/habitmove/repetitions.py index bfd21ba..42b00f3 100644 --- a/src/habitmove/repetitions.py +++ b/src/habitmove/repetitions.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import sqlite3 from typing import Optional from datetime import datetime diff --git a/src/habitmove/schema.py b/src/habitmove/schema.py index e5e8404..17272e8 100644 --- a/src/habitmove/schema.py +++ b/src/habitmove/schema.py @@ -1,7 +1,7 @@ import sqlite3 -def create_database(name): +def create_database(db_file: str) -> sqlite3.Connection: """create a database connection to the SQLite database specified by db_file :param db_file: database file @@ -9,13 +9,11 @@ def create_database(name): """ conn = None try: - conn = sqlite3.connect(name) + conn = sqlite3.connect(db_file) return conn except sqlite3.Error as e: print(e) - return conn - def create_tables(db): c = db.cursor()