diff --git a/.envrc b/.envrc index ad11962..76f03ce 100644 --- a/.envrc +++ b/.envrc @@ -1,4 +1 @@ -make venv > /dev/null -source venv/bin/activate - dotenv_if_exists .env diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c5b7bd0..d424257 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,30 +7,40 @@ jobs: steps: - uses: actions/checkout@v3 - name: Black - uses: microsoft/action-python@0.7.0 + uses: microsoft/action-python@0.7.2 with: workdir: . black: true + python_version: "3.12" - name: Flake8 - uses: microsoft/action-python@0.7.0 + uses: microsoft/action-python@0.7.2 with: workdir: . flake8: true + python_version: "3.12" pytest: runs-on: ubuntu-latest strategy: matrix: python-version: - - "3.8" - "3.9" - "3.10" - "3.11" + - "3.12" steps: - uses: actions/checkout@v3 - - name: Pytest - uses: microsoft/action-python@0.7.0 + - uses: actions/setup-python@v5 with: - workdir: . - testing: true - python_version: ${{ matrix.python-version }} + python-version: ${{ matrix.python-version }} + cache: 'pip' + cache-dependency-path: | + **/requirements.txt + **/requirements-dev.txt + - name: Install deps + run: | + pip install -r requirements.txt + pip install -r requirements-dev.txt + - name: Pytest + run: | + python -m pytest diff --git a/Makefile b/Makefile index 7fbb8d5..0467bf9 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -VENV_BIN ?= python3.11 -m venv +VENV_BIN ?= python3 -m venv VENV_DIR ?= venv PIP_CMD ?= pip3 @@ -21,15 +21,15 @@ $(VENV_ACTIVATE): setup.py setup.cfg venv: $(VENV_ACTIVATE) ## Create a new (empty) virtual environment freeze: ## Run pip freeze -l in the virtual environment - @$(VENV_RUN); pip freeze -l + @$(VENV_RUN); $(PIP_CMD) freeze -l pre-commit: ## Install pre-commit hooks - @pre-commit install > /dev/null + @$(VENV_RUN); pre-commit install > /dev/null install: ## Install full dependencies into venv make install-lib make install-dev - @make pre-commit + make pre-commit install-dev: venv ## Install requirements for development into venv @$(VENV_RUN); $(PIP_CMD) install -r requirements-dev.txt @@ -39,19 +39,19 @@ install-lib: venv ## Install requirements for godaddypy into venv dist: ## Build distributions @$(VENV_RUN); pip install --upgrade twine build; - python -m build + @$(VENV_RUN); python -m build publish: clean-dist dist ## Publish the library to the central PyPi repository $(VENV_RUN); twine upload dist/* test: ## Run tests via PyTest - @$(VENV_RUN); pytest + @$(VENV_RUN); python -m pytest lint: ## Run linter @$(VENV_RUN); python -m pflake8 --show-source -format: - @$(VENV_RUN); python -m black examples godaddypy tests +format: ## Run formatting + @$(VENV_RUN); python -m black . clean: ## Clean up everything rm -f .coverage diff --git a/godaddypy/account.py b/godaddypy/account.py index fbf745c..664872a 100644 --- a/godaddypy/account.py +++ b/godaddypy/account.py @@ -5,6 +5,7 @@ from os import environ, path, makedirs from pathlib import Path from sys import stdout +from typing import Union import yaml from configloader import ConfigLoader @@ -100,7 +101,7 @@ def __init__(self, api_key=None, api_secret=None, delegate=None, log_level=None) self.__api_secret = self.__api_secret or (config.secret if config else api_secret) self._config = config - def __parse_configuration(self) -> Configuration | None: + def __parse_configuration(self) -> Union[Configuration, None]: # Get config from environment env_config = self.__parse_env() @@ -111,7 +112,7 @@ def __parse_configuration(self) -> Configuration | None: # See: https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html return self.__parse_file() - def __parse_file(self) -> Configuration | None: + def __parse_file(self) -> Union[Configuration, None]: if not self or not path.exists(self._config_path): return None @@ -131,7 +132,7 @@ def __parse_file(self) -> Configuration | None: return Configuration(key=key, secret=secret) - def __parse_env(self) -> Configuration | None: + def __parse_env(self) -> Union[Configuration, None]: config = ConfigLoader() config.update_from_env_namespace("GODADDY_API") diff --git a/pyproject.toml b/pyproject.toml index 584be8c..7d329ba 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.black] line-length = 120 -target-version = ['py38'] +target-version = ['py39'] [tool.flake8] max-line-length = 120 diff --git a/setup.py b/setup.py index 6799625..43b8ef7 100644 --- a/setup.py +++ b/setup.py @@ -7,6 +7,7 @@ CURRENT_DIR = os.path.abspath(os.path.dirname(__file__)) + def get_reqs(*fns): lst = [] for fn in fns: @@ -17,6 +18,7 @@ def get_reqs(*fns): lst.append(package.strip()) return lst + with open("godaddypy/__init__.py", "r") as f: version_match = re.search(r"^__version__\s*=\s*[\'\"]([^\'\"]*)[\'\"]", f.read(), re.MULTILINE) @@ -37,8 +39,8 @@ def get_reqs(*fns): author_email="julian.calvin.coy@gmail.com", url="https://github.com/eXamadeus/godaddypy", packages=["godaddypy"], - install_requires=get_reqs('requirements.txt'), - tests_require=get_reqs('requirements-dev.txt'), + install_requires=get_reqs("requirements.txt"), + tests_require=get_reqs("requirements-dev.txt"), classifiers=[ "Development Status :: 5 - Production/Stable", "Intended Audience :: Developers",