Skip to content

Commit

Permalink
feat: Drop support for Python 3.7
Browse files Browse the repository at this point in the history
  • Loading branch information
edgarrmondragon committed Aug 17, 2023
1 parent f545682 commit a70cda0
Show file tree
Hide file tree
Showing 12 changed files with 237 additions and 306 deletions.
5 changes: 5 additions & 0 deletions .changes/unreleased/Changed-20230629-202540.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
kind: Changed
body: Drop support for Python 3.7
time: 2023-06-29T20:25:40.318839-06:00
custom:
Issue: "617"
4 changes: 1 addition & 3 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,11 @@ jobs:
fail-fast: false
matrix:
python-version:
- "3.7"
- "3.8"
- "3.9"
- "3.10"
- "3.11"
- "3.12"
- "pypy3.7"
- "pypy3.8"
- "pypy3.9"
- "pypy3.10"
Expand Down Expand Up @@ -271,7 +269,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12"]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
steps:
- name: Check out the repository
uses: actions/[email protected]
Expand Down
2 changes: 1 addition & 1 deletion .sonarcloud.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sonar.python.version=3.7, 3.8, 3.9, 3.10
sonar.python.version=3.8, 3.9, 3.10, 3.11
4 changes: 2 additions & 2 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@

package = "citric"

python_versions = ["3.11", "3.10", "3.9", "3.8", "3.7"]
pypy_versions = ["pypy3.7", "pypy3.8", "pypy3.9", "pypy3.10"]
python_versions = ["3.11", "3.10", "3.9", "3.8"]
pypy_versions = ["pypy3.8", "pypy3.9", "pypy3.10"]
all_python_versions = python_versions + pypy_versions

main_cpython_version = "3.11"
Expand Down
426 changes: 188 additions & 238 deletions poetry.lock

Large diffs are not rendered by default.

10 changes: 4 additions & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ classifiers = [
"License :: OSI Approved :: MIT License",
"Natural Language :: English",
"Operating System :: OS Independent",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
Expand All @@ -34,12 +33,11 @@ version = "0.7.2"
"Issue Tracker" = "https://github.com/edgarrmondragon/citric/issues"

[tool.poetry.dependencies]
importlib_metadata = { version = ">=1.6", python = "<3.8" }
python = ">=3.7.0"
python = ">=3.8"
requests = ">=2.23.0"

# Docs
furo = { version = ">=2023.3.27", optional = true }
furo = { version = ">=2023.3.27,<2023.08.17", optional = true }
myst-parser = { version = ">=1.0.0,<2", optional = true }
sphinx = { version = "<7", optional = true }
sphinx-autoapi = { version = ">=2.1.0,<3", optional = true }
Expand All @@ -54,7 +52,7 @@ faker = ">=18.3.1,<19"
mypy = "^1.4.1"
pytest = ">=7.3.1,<8"
pytest-github-actions-annotate-failures = ">=0.1.7,<0.3.0"
python-dotenv = ">=0.21.1,<1"
python-dotenv = "<2"
safety = ">=2.1.1,<3"
types-requests = "^2.31.0.2"
typing-extensions = { version = ">=4.6.0,<5", python = "<3.12" }
Expand Down Expand Up @@ -85,7 +83,7 @@ include = ["*.py", "*.pyi", "**/pyproject.toml", "*.ipynb"]
line-length = 88
select = ["ALL"]
src = ["src", "tests", "docs"]
target-version = "py37"
target-version = "py38"

[tool.ruff.per-file-ignores]
"docs/notebooks/*" = [
Expand Down
9 changes: 2 additions & 7 deletions src/citric/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,13 @@

from __future__ import annotations

import sys
from importlib import metadata

from citric.client import Client

if sys.version_info >= (3, 8):
from importlib import metadata
else:
import importlib_metadata as metadata

__version__ = metadata.version(__package__)
"""Package version"""

del annotations, metadata, sys
del annotations, metadata

__all__ = ["Client"]
7 changes: 1 addition & 6 deletions src/citric/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,6 @@
from citric import types
from citric.objects import Participant

if sys.version_info >= (3, 8):
from typing import Literal # noqa: ICN003
else:
from typing_extensions import Literal

if sys.version_info >= (3, 11):
from typing import Self, Unpack # noqa: ICN003
else:
Expand Down Expand Up @@ -827,7 +822,7 @@ def save_statistics(
def export_timeline(
self,
survey_id: int,
period: Literal["day", "hour"] | enums.TimelineAggregationPeriod,
period: t.Literal["day", "hour"] | enums.TimelineAggregationPeriod,
start: datetime.datetime,
end: datetime.datetime | None = None,
) -> dict[str, int]:
Expand Down
8 changes: 2 additions & 6 deletions src/citric/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
import json
import logging
import random
import sys
import typing as t
from importlib import metadata

import requests

Expand All @@ -19,12 +19,8 @@
)
from citric.method import Method

if sys.version_info >= (3, 8):
from importlib import metadata
else:
import importlib_metadata as metadata

if t.TYPE_CHECKING:
import sys
from types import TracebackType

from citric.types import Result, RPCResponse
Expand Down
42 changes: 19 additions & 23 deletions src/citric/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,23 @@

from __future__ import annotations

import sys
import typing as t

if sys.version_info >= (3, 8):
from typing import Literal, TypedDict # noqa: ICN003
else:
from typing_extensions import Literal, TypedDict
if t.TYPE_CHECKING:
import sys

if sys.version_info >= (3, 10):
from typing import TypeAlias # noqa: ICN003
else:
from typing_extensions import TypeAlias
if sys.version_info >= (3, 10):
from typing import TypeAlias # noqa: ICN003
else:
from typing_extensions import TypeAlias

if t.TYPE_CHECKING:
from citric import enums

Result: TypeAlias = t.Any
YesNo: TypeAlias = Literal["Y", "N"]
YesNo: TypeAlias = t.Literal["Y", "N"]


class FileUploadResult(TypedDict):
class FileUploadResult(t.TypedDict):
"""File upload result.
Keys:
Expand All @@ -42,7 +38,7 @@ class FileUploadResult(TypedDict):
msg: str


class GroupProperties(TypedDict, total=False):
class GroupProperties(t.TypedDict, total=False):
"""Group properties.
Keys:
Expand All @@ -64,7 +60,7 @@ class GroupProperties(TypedDict, total=False):
description: str


class LanguageProperties(TypedDict, total=False):
class LanguageProperties(t.TypedDict, total=False):
"""Language properties.
Keys:
Expand Down Expand Up @@ -138,7 +134,7 @@ class LanguageProperties(TypedDict, total=False):
attachments: str | None


class OperationStatus(TypedDict):
class OperationStatus(t.TypedDict):
"""Delete language result.
Keys:
Expand All @@ -148,7 +144,7 @@ class OperationStatus(TypedDict):
status: str


class QuestionsListElement(TypedDict):
class QuestionsListElement(t.TypedDict):
"""List questions result.
Keys:
Expand Down Expand Up @@ -202,7 +198,7 @@ class QuestionsListElement(TypedDict):
same_script: int


class QuestionProperties(TypedDict, total=False):
class QuestionProperties(t.TypedDict, total=False):
"""Question properties result.
Keys:
Expand Down Expand Up @@ -263,7 +259,7 @@ class QuestionProperties(TypedDict, total=False):
attributes_lang: dict[str, t.Any]


class QuotaListElement(TypedDict):
class QuotaListElement(t.TypedDict):
"""List quotas result.
Keys:
Expand All @@ -283,7 +279,7 @@ class QuotaListElement(TypedDict):
autoload_url: int


class QuotaProperties(TypedDict, total=False):
class QuotaProperties(t.TypedDict, total=False):
"""Quota properties result.
Keys:
Expand All @@ -305,7 +301,7 @@ class QuotaProperties(TypedDict, total=False):
autoload_url: int


class RPCResponse(TypedDict):
class RPCResponse(t.TypedDict):
"""RPC response payload.
Keys:
Expand All @@ -319,7 +315,7 @@ class RPCResponse(TypedDict):
error: str | None


class SetQuotaPropertiesResult(TypedDict):
class SetQuotaPropertiesResult(t.TypedDict):
"""Set quota properties result.
Keys:
Expand All @@ -331,7 +327,7 @@ class SetQuotaPropertiesResult(TypedDict):
message: QuotaProperties


class SurveyProperties(TypedDict, total=False):
class SurveyProperties(t.TypedDict, total=False):
"""Survey properties result.
Keys:
Expand Down Expand Up @@ -473,7 +469,7 @@ class SurveyProperties(TypedDict, total=False):
additional_languages: str


class CPDBParticipantImportResult(TypedDict):
class CPDBParticipantImportResult(t.TypedDict):
"""CPDB participant import result.
Keys:
Expand Down
20 changes: 9 additions & 11 deletions tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

import base64
import datetime
import random
import sys
import typing as t
from pathlib import Path
Expand All @@ -15,6 +14,15 @@
from citric.enums import ImportGroupType, ImportSurveyType, NewSurveyType
from citric.session import Session

if sys.version_info >= (3, 9):
from random import randbytes
else:
from random import getrandbits

def randbytes(n: int) -> bytes: # noqa: D103
return getrandbits(n * 8).to_bytes(n, "little")


if t.TYPE_CHECKING:
from _pytest._py.path import LocalPath
from faker import Faker
Expand All @@ -24,16 +32,6 @@
NEW_SURVEY_NAME = "New Survey"


def _get_random_bytes(n: int) -> bytes:
return random.getrandbits(n * 8).to_bytes(n, "little")


if sys.version_info >= (3, 9):
randbytes = random.randbytes
else:
randbytes = _get_random_bytes


class MockSession(Session):
"""Mock RPC session with some hardcoded methods for testing."""

Expand Down
6 changes: 3 additions & 3 deletions tests/test_rpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@

from .conftest import LimeSurveyMockAdapter

if sys.version_info < (3, 11):
SET_PROPERTY_MESSAGE_REGEX = "can't set attribute"
else:
if sys.version_info >= (3, 11):
SET_PROPERTY_MESSAGE_REGEX = "property .* of 'Session' object has no setter"
else:
SET_PROPERTY_MESSAGE_REGEX = "can't set attribute"


class RPCOffAdapter(LimeSurveyMockAdapter):
Expand Down

0 comments on commit a70cda0

Please sign in to comment.