-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: upgrade all dependencies, PostgreSQL 10->13, use ruff
Done: - Upgrade all dependencies - Upgrade postgresql from v10 to v13 (v13 is used in production) - Use ruff instead of black/isort/flake8, remove noqa's, reformat - Use pyproject.toml instead of setup.cfg Background for @map_enums_to_values_in_kwargs decorator: Graphene 3 changed from using enum values to enums, for example: ```python class TestEnum(graphene.Enum): FIRST = 'first' SECOND = 'second' ``` would've been serialized previously using the enum values, i.e. 'first' and 'second'. But with Graphene 3 they are serialized as 'TestEnum.FIRST' and 'TestEnum.SECOND'. This broke functionality as parts of the codebase were expecting the enum values as per Graphene 2. Forced backwards compatibility by forcefully mapping enums to their values. Related https://github.com/graphql-python/graphene issues & PRs: - "Improve enum compatibility" PR: - graphql-python/graphene#1153 - "graphene3: enum doesn't resolve to value" issue: - graphql-python/graphene#1277 - "I would like my enum input values to be the enum instance instead of the enum values" issue: - graphql-python/graphene#1151 See https://github.com/graphql-python/graphene/wiki/v3-release-notes for Graphene v3's breaking changes, refs PT-1730
- Loading branch information
1 parent
b736d8a
commit bcbf88b
Showing
80 changed files
with
4,205 additions
and
2,989 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,18 @@ | ||
# See https://pre-commit.com for more information | ||
# See https://pre-commit.com/hooks.html for more hooks | ||
# Pre-commit hook documentation: | ||
# - https://pre-commit.com/ | ||
# - https://pre-commit.com/hooks.html | ||
# | ||
# Ruff pre-commit hook documentation: | ||
# - https://github.com/astral-sh/ruff-pre-commit | ||
default_language_version: | ||
python: python3.11 | ||
repos: | ||
- repo: https://github.com/PyCQA/isort | ||
rev: 5.12.0 | ||
- repo: https://github.com/astral-sh/ruff-pre-commit | ||
# Ruff version | ||
rev: v0.6.9 | ||
hooks: | ||
- id: isort | ||
- repo: https://github.com/psf/black | ||
rev: 23.3.0 | ||
hooks: | ||
- id: black | ||
- repo: https://github.com/PyCQA/flake8 | ||
rev: 6.0.0 | ||
hooks: | ||
- id: flake8 | ||
exclude: migrations|snapshots | ||
# Run the linter | ||
- id: ruff | ||
args: [ --fix ] | ||
# Run the formatter | ||
- id: ruff-format |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
class SaveAfterPostGenerationMixin: | ||
""" | ||
Mixin for saving Django model instances after post-generation hooks. | ||
To use this derive the factory class that uses @factory.post_generation | ||
decorator from factory.django.DjangoModelFactory as well as this, e.g. | ||
class TestFactory(SaveAfterPostGenerationMixin, factory.django.DjangoModelFactory) | ||
NOTE: Needs to be before factory.django.DjangoModelFactory in the class | ||
definition to work, because of how Python resolves method resolution order (MRO). | ||
Rationale: | ||
- Because factory 3.3.0 has deprecated saving the instance after | ||
post-generation hooks, and will remove the functionality in the | ||
next major release. | ||
""" | ||
|
||
@classmethod | ||
def _after_postgeneration(cls, instance, create, results=None): | ||
"""Save again the instance if creating and at least one hook ran.""" | ||
if create and results: | ||
# Some post-generation hooks ran, and may have modified us. | ||
instance.save() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
import json | ||
import logging | ||
|
||
import requests | ||
|
||
logger = logging.getLogger(__name__) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.