Skip to content

Commit

Permalink
Chore: Verify support for Python>=3.6
Browse files Browse the repository at this point in the history
  • Loading branch information
amotl committed Apr 23, 2024
1 parent 2d7f44d commit a333ab6
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 13 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: ["ubuntu-latest"]
python-version: ["3.9", "3.12"]
os: ["ubuntu-20.04"]
python-version: ["3.6", "3.12"]
fail-fast: false

env:
Expand Down Expand Up @@ -51,7 +51,7 @@ jobs:
# `setuptools 0.64.0` adds support for editable install hooks (PEP 660).
# https://github.com/pypa/setuptools/blob/main/CHANGES.rst#v6400
pip install "setuptools>=64" --upgrade
pip install pip setuptools --upgrade
# Install package in editable mode.
pip install --use-pep517 --prefer-binary --editable=.[test,develop]
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,10 @@ format = [
]

lint = [
{ cmd = "ruff check ." },
{ shell = "ruff check . || true" },
# { cmd = "black --check ." },
{ cmd = "validate-pyproject pyproject.toml" },
{ cmd = "mypy" },
{ cmd = "mypy grafana_import" },
]

release = [
Expand Down
12 changes: 9 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,15 @@
"black<25",
"mypy<1.10",
"poethepoet<0.26",
"pyproject-fmt<1.8",
"ruff<0.5",
"pyproject-fmt<1.8; python_version>='3.7'",
"ruff<0.5; python_version>='3.7'",
"validate-pyproject<0.17",
],
"test": [
"grafana-dashboard==0.1.1",
"grafana-dashboard<0.2; python_version>='3.7'",
"importlib-resources<7; python_version<'3.9'",
# Pydantic is pulled in by grafana-dashboard. Pydantic 1.x is needed on Python 3.12.
# Otherwise, `Error when building FieldInfo from annotated attribute` happens.
"pydantic<2",
"pytest<9",
"pytest-cov<6",
Expand Down Expand Up @@ -67,6 +70,9 @@
"Operating System :: Unix",
"Operating System :: MacOS",
"Programming Language :: Python",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
Expand Down
14 changes: 12 additions & 2 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
from importlib.resources import files
import sys

if sys.version_info < (3, 9):
from importlib_resources import files
else:
from importlib.resources import files

import pytest
import responses
Expand All @@ -15,7 +20,10 @@ def niquests_patch_all():
"""
from sys import modules

import niquests
try:
import niquests
except ImportError:
return
import urllib3

# Amalgamate the module namespace to make all modules aiming
Expand All @@ -32,6 +40,8 @@ def mocked_responses():
"""
Provide the `responses` mocking machinery to a pytest environment.
"""
if sys.version_info < (3, 7):
raise pytest.skip("Does not work on Python 3.6")
with responses.RequestsMock() as rsps:
yield rsps

Expand Down
12 changes: 9 additions & 3 deletions tests/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@
import json
import typing as t

from grafana_dashboard.manual_models import TimeSeries
from grafana_dashboard.model.dashboard_types_gen import Dashboard, GridPos
from grafana_dashboard.model.prometheusdataquery_types_gen import PrometheusDataQuery
import pytest
from responses import RequestsMock

if t.TYPE_CHECKING:
Expand Down Expand Up @@ -39,6 +37,14 @@ def mkdashboard():
https://github.com/fzyzcjy/grafana_dashboard_python/blob/master/examples/python_to_json/input_python/dashboard-one.py
"""
pytest.importorskip(
"grafana_dashboard",
reason="Skipping dashboard generation because `grafana-dashboard` is not available")

from grafana_dashboard.manual_models import TimeSeries
from grafana_dashboard.model.dashboard_types_gen import Dashboard, GridPos
from grafana_dashboard.model.prometheusdataquery_types_gen import PrometheusDataQuery

dashboard = Dashboard(
title='Dashboard One',
panels=[
Expand Down

0 comments on commit a333ab6

Please sign in to comment.