From 44dcdad18277e11d8e7d53ce8c8a16aa265d69b9 Mon Sep 17 00:00:00 2001 From: Dulmandakh Date: Thu, 13 Jun 2024 22:32:50 +0800 Subject: [PATCH 1/6] CI: fix deprecation warning (#1551) --- .github/workflows/tests.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 76a72c45..0fdc7c45 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -42,14 +42,12 @@ jobs: - name: get pip cache dir id: pip-cache - run: echo "::set-output name=dir::$(pip cache dir)" - + run: echo "dir=$(pip cache dir)" >> $GITHUB_OUTPUT - name: cache pip dependencies uses: actions/cache@v3 with: path: ${{ steps.pip-cache.outputs.dir }} key: pip|${{ runner.os }}|${{ matrix.python }}|${{ hashFiles('setup.py') }} - - run: pip install tox - run: tox -e ${{ matrix.tox }} - name: Upload coverage.xml From 614449e65193252209378cdf5bcbb97e20ab08be Mon Sep 17 00:00:00 2001 From: Dulmandakh Date: Thu, 13 Jun 2024 22:34:16 +0800 Subject: [PATCH 2/6] Python 3.12 (#1550) * python 3.12 * update classifiers --- .github/workflows/tests.yml | 1 + docs/quickstart.rst | 2 +- setup.py | 1 + tox.ini | 4 ++-- 4 files changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 0fdc7c45..0389d7ad 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -25,6 +25,7 @@ jobs: fail-fast: false matrix: include: + - {name: '3.12', python: '3.12', os: ubuntu-latest, tox: py312} - {name: '3.11', python: '3.11', os: ubuntu-latest, tox: py311} - {name: '3.10', python: '3.10', os: ubuntu-latest, tox: py310} - {name: '3.9', python: '3.9', os: ubuntu-latest, tox: py39} diff --git a/docs/quickstart.rst b/docs/quickstart.rst index e06b12bb..31f51500 100644 --- a/docs/quickstart.rst +++ b/docs/quickstart.rst @@ -59,7 +59,7 @@ When we send a **Query** requesting only one **Field**, ``hello``, and specify a Requirements ~~~~~~~~~~~~ -- Python (3.8, 3.9, 3.10, 3.11, pypy) +- Python (3.8, 3.9, 3.10, 3.11, 3.12, pypy) - Graphene (3.0) Project setup diff --git a/setup.py b/setup.py index 1600297a..c40ca89f 100644 --- a/setup.py +++ b/setup.py @@ -77,6 +77,7 @@ setup( "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", ], keywords="api graphql protocol rest relay graphene", packages=find_packages(exclude=["examples*"]), diff --git a/tox.ini b/tox.ini index 2b245f28..767f957c 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = py3{8,9,10,11}, mypy, pre-commit +envlist = py3{8,9,10,11,12}, mypy, pre-commit skipsdist = true [testenv] @@ -8,7 +8,7 @@ deps = setenv = PYTHONPATH = .:{envdir} commands = - py{38,39,310,311}: pytest --cov=graphene graphene --cov-report=term --cov-report=xml examples {posargs} + py{38,39,310,311,12}: pytest --cov=graphene graphene --cov-report=term --cov-report=xml examples {posargs} [testenv:pre-commit] basepython = python3.10 From 17d09c8dedce36e2e0ea7dff4abf73bf3b39c541 Mon Sep 17 00:00:00 2001 From: Dulmandakh Date: Thu, 13 Jun 2024 22:35:00 +0800 Subject: [PATCH 3/6] remove aniso8601, mock, iso8601 (#1548) * remove aniso8601 * remove mock, iso8601 --------- Co-authored-by: Erik Wrede --- .isort.cfg | 2 +- graphene/types/datetime.py | 7 +++---- setup.py | 3 --- 3 files changed, 4 insertions(+), 8 deletions(-) diff --git a/.isort.cfg b/.isort.cfg index 02dbdee4..42fa707d 100644 --- a/.isort.cfg +++ b/.isort.cfg @@ -1,2 +1,2 @@ [settings] -known_third_party = aniso8601,graphql,graphql_relay,promise,pytest,pyutils,setuptools,snapshottest,sphinx_graphene_theme +known_third_party = graphql,graphql_relay,promise,pytest,pyutils,setuptools,snapshottest,sphinx_graphene_theme diff --git a/graphene/types/datetime.py b/graphene/types/datetime.py index d4f74470..a22c5cd3 100644 --- a/graphene/types/datetime.py +++ b/graphene/types/datetime.py @@ -2,7 +2,6 @@ from __future__ import absolute_import import datetime -from aniso8601 import parse_date, parse_datetime, parse_time from graphql.error import GraphQLError from graphql.language import StringValueNode, print_ast @@ -39,7 +38,7 @@ class Date(Scalar): if not isinstance(value, str): raise GraphQLError(f"Date cannot represent non-string value: {repr(value)}") try: - return parse_date(value) + return datetime.date.fromisoformat(value) except ValueError: raise GraphQLError(f"Date cannot represent value: {repr(value)}") @@ -74,7 +73,7 @@ class DateTime(Scalar): f"DateTime cannot represent non-string value: {repr(value)}" ) try: - return parse_datetime(value) + return datetime.datetime.fromisoformat(value) except ValueError: raise GraphQLError(f"DateTime cannot represent value: {repr(value)}") @@ -107,6 +106,6 @@ class Time(Scalar): if not isinstance(value, str): raise GraphQLError(f"Time cannot represent non-string value: {repr(value)}") try: - return parse_time(value) + return datetime.time.fromisoformat(value) except ValueError: raise GraphQLError(f"Time cannot represent value: {repr(value)}") diff --git a/setup.py b/setup.py index c40ca89f..6ae8a1d5 100644 --- a/setup.py +++ b/setup.py @@ -52,8 +52,6 @@ tests_require = [ "pytest-asyncio>=0.16,<2", "snapshottest>=0.6,<1", "coveralls>=3.3,<4", - "mock>=4,<5", - "iso8601>=1,<2", ] dev_requires = ["black==22.3.0", "flake8>=4,<5"] + tests_require @@ -84,7 +82,6 @@ setup( install_requires=[ "graphql-core>=3.1,<3.3", "graphql-relay>=3.1,<3.3", - "aniso8601>=8,<10", ], tests_require=tests_require, extras_require={"test": tests_require, "dev": dev_requires}, From 88c3ec539bf77975dbea97431ed1d352a5d772be Mon Sep 17 00:00:00 2001 From: tijuca Date: Thu, 13 Jun 2024 16:38:48 +0200 Subject: [PATCH 4/6] pytest: Don't use nose like syntax in graphene/relay/tests/test_custom_global_id.py (#1539) (#1540) pytest: Don't use nose like syntax The tests in test_custom_global_id.py use the old nose specific method 'setup(self)' which isn't supported anymore in Pytest 8+. The tests fail with this error message without modification. E pytest.PytestRemovedIn8Warning: Support for nose tests is deprecated and will be removed in a future release. E graphene/relay/tests/test_custom_global_id.py::TestIncompleteCustomGlobalID::test_must_define_resolve_global_id is using nose-specific method: `setup(self)` E To remove this warning, rename it to `setup_method(self)` E See docs: https://docs.pytest.org/en/stable/deprecations.html#support-for-tests-written-for-nose Co-authored-by: Erik Wrede --- graphene/relay/tests/test_custom_global_id.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/graphene/relay/tests/test_custom_global_id.py b/graphene/relay/tests/test_custom_global_id.py index c1bf0fb4..8f799140 100644 --- a/graphene/relay/tests/test_custom_global_id.py +++ b/graphene/relay/tests/test_custom_global_id.py @@ -9,7 +9,7 @@ from ...types import Int, ObjectType, Schema, String class TestUUIDGlobalID: - def setup(self): + def setup_method(self): self.user_list = [ {"id": uuid4(), "name": "First"}, {"id": uuid4(), "name": "Second"}, @@ -77,7 +77,7 @@ class TestUUIDGlobalID: class TestSimpleGlobalID: - def setup(self): + def setup_method(self): self.user_list = [ {"id": "my global primary key in clear 1", "name": "First"}, {"id": "my global primary key in clear 2", "name": "Second"}, @@ -140,7 +140,7 @@ class TestSimpleGlobalID: class TestCustomGlobalID: - def setup(self): + def setup_method(self): self.user_list = [ {"id": 1, "name": "First"}, {"id": 2, "name": "Second"}, @@ -219,7 +219,7 @@ class TestCustomGlobalID: class TestIncompleteCustomGlobalID: - def setup(self): + def setup_method(self): self.user_list = [ {"id": 1, "name": "First"}, {"id": 2, "name": "Second"}, From 6a668514debf091269cd6fe04d56fd53c8646b8b Mon Sep 17 00:00:00 2001 From: Erik Wrede Date: Thu, 13 Jun 2024 16:51:43 +0200 Subject: [PATCH 5/6] docs: create security.md (#1554) --- SECURITY.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 SECURITY.md diff --git a/SECURITY.md b/SECURITY.md new file mode 100644 index 00000000..5b58ab62 --- /dev/null +++ b/SECURITY.md @@ -0,0 +1,15 @@ +# Security Policy + +## Supported Versions + +Support for security issues is currently provided for Graphene 3.0 and above. Support on earlier versions cannot be guaranteed by the maintainers of this library, but community PRs may be accepted in critical cases. +The preferred mitigation strategy is via an upgrade to Graphene 3. + +| Version | Supported | +| ------- | ------------------ | +| 3.x | :white_check_mark: | +| <3.x | :x: | + +## Reporting a Vulnerability + +Please use responsible disclosure by contacting a core maintainer via Discord or E-Mail. From 5924cc4150be4a08c6f31bbfa9fcc8a3f3ab1a4f Mon Sep 17 00:00:00 2001 From: Dulmandakh Date: Thu, 13 Jun 2024 22:52:06 +0800 Subject: [PATCH 6/6] remove Python 2 (#1547) Co-authored-by: Erik Wrede --- examples/starwars/tests/snapshots/snap_test_query.py | 2 -- .../starwars_relay/tests/snapshots/snap_test_connections.py | 2 -- examples/starwars_relay/tests/snapshots/snap_test_mutation.py | 2 -- .../tests/snapshots/snap_test_objectidentification.py | 2 -- graphene/pyutils/version.py | 2 -- graphene/types/datetime.py | 2 -- graphene/types/decimal.py | 2 -- graphene/types/generic.py | 2 -- graphene/types/json.py | 2 -- graphene/types/uuid.py | 1 - 10 files changed, 19 deletions(-) diff --git a/examples/starwars/tests/snapshots/snap_test_query.py b/examples/starwars/tests/snapshots/snap_test_query.py index b4f05bdb..1ede86e4 100644 --- a/examples/starwars/tests/snapshots/snap_test_query.py +++ b/examples/starwars/tests/snapshots/snap_test_query.py @@ -1,7 +1,5 @@ # -*- coding: utf-8 -*- # snapshottest: v1 - https://goo.gl/zC4yUc -from __future__ import unicode_literals - from snapshottest import Snapshot snapshots = Snapshot() diff --git a/examples/starwars_relay/tests/snapshots/snap_test_connections.py b/examples/starwars_relay/tests/snapshots/snap_test_connections.py index 57a7b7ea..353fee59 100644 --- a/examples/starwars_relay/tests/snapshots/snap_test_connections.py +++ b/examples/starwars_relay/tests/snapshots/snap_test_connections.py @@ -1,7 +1,5 @@ # -*- coding: utf-8 -*- # snapshottest: v1 - https://goo.gl/zC4yUc -from __future__ import unicode_literals - from snapshottest import Snapshot snapshots = Snapshot() diff --git a/examples/starwars_relay/tests/snapshots/snap_test_mutation.py b/examples/starwars_relay/tests/snapshots/snap_test_mutation.py index c35b2aeb..f0012e0a 100644 --- a/examples/starwars_relay/tests/snapshots/snap_test_mutation.py +++ b/examples/starwars_relay/tests/snapshots/snap_test_mutation.py @@ -1,7 +1,5 @@ # -*- coding: utf-8 -*- # snapshottest: v1 - https://goo.gl/zC4yUc -from __future__ import unicode_literals - from snapshottest import Snapshot snapshots = Snapshot() diff --git a/examples/starwars_relay/tests/snapshots/snap_test_objectidentification.py b/examples/starwars_relay/tests/snapshots/snap_test_objectidentification.py index b02a420c..ab83e358 100644 --- a/examples/starwars_relay/tests/snapshots/snap_test_objectidentification.py +++ b/examples/starwars_relay/tests/snapshots/snap_test_objectidentification.py @@ -1,7 +1,5 @@ # -*- coding: utf-8 -*- # snapshottest: v1 - https://goo.gl/zC4yUc -from __future__ import unicode_literals - from snapshottest import Snapshot diff --git a/graphene/pyutils/version.py b/graphene/pyutils/version.py index 8a3be07a..c5f893f5 100644 --- a/graphene/pyutils/version.py +++ b/graphene/pyutils/version.py @@ -1,5 +1,3 @@ -from __future__ import unicode_literals - import datetime import os import subprocess diff --git a/graphene/types/datetime.py b/graphene/types/datetime.py index a22c5cd3..7bfd9bd2 100644 --- a/graphene/types/datetime.py +++ b/graphene/types/datetime.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import - import datetime from graphql.error import GraphQLError diff --git a/graphene/types/decimal.py b/graphene/types/decimal.py index 0c6ccc97..69952f96 100644 --- a/graphene/types/decimal.py +++ b/graphene/types/decimal.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import - from decimal import Decimal as _Decimal from graphql import Undefined diff --git a/graphene/types/generic.py b/graphene/types/generic.py index 2a3c8d52..1c007211 100644 --- a/graphene/types/generic.py +++ b/graphene/types/generic.py @@ -1,5 +1,3 @@ -from __future__ import unicode_literals - from graphql.language.ast import ( BooleanValueNode, FloatValueNode, diff --git a/graphene/types/json.py b/graphene/types/json.py index ca55836b..806d1be6 100644 --- a/graphene/types/json.py +++ b/graphene/types/json.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import - import json from graphql import Undefined diff --git a/graphene/types/uuid.py b/graphene/types/uuid.py index f2ba1fcb..773e31c7 100644 --- a/graphene/types/uuid.py +++ b/graphene/types/uuid.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import from uuid import UUID as _UUID from graphql.language.ast import StringValueNode