Skip to content

Commit

Permalink
Feat: Package & Dependency Management using Poetry (#210)
Browse files Browse the repository at this point in the history
* feat(Poetry): Adds Pyproject file for poetry

* feat(Dependencies): Drops support of Python 3.6 (End of Life), bumps mongoengine to latest 0.27

* fix(Tests): Fix import names of pytest

* fix(Dependencies): Locks dependencies using poetry.lock

* fix(Dependencies): Adds Coveralls dependency

* feat(Packaging): Removed unused setup.py and requirements.txt, [WIP] updated Makefile

* refactor(Converter): Remove unused import

* refactor(Fields): Fixes lint issues, logs error

* fix(Dev Dependecies): Adds Twine [Intermediate for migration from setup.py to pyproject]

* fix: migration patch for uploading to pypi
  • Loading branch information
abhinand-c authored Mar 30, 2023
1 parent 2702142 commit 40ee17b
Show file tree
Hide file tree
Showing 9 changed files with 1,315 additions and 69 deletions.
14 changes: 9 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,21 @@ lint:
@flake8 graphene_mongo

test: clean lint
py.test graphene_mongo/tests --cov=graphene_mongo --cov-report=html --cov-report=term
pytest graphene_mongo/tests --cov=graphene_mongo --cov-report=html --cov-report=term

register-pypitest:
python setup.py register -r pypitest
#python setup.py register -r pypitest

deploy-pypitest: clean
python setup.py sdist upload -r pypitest
poetry build
#poetry publish --repository testpypi
twine upload --repository testpypi dist/*

register:
python setup.py register -r pypi
#python setup.py register -r pypi

deploy: clean
python setup.py sdist upload -r pypi
poetry build
twine upload dist/*
#poetry publish

1 change: 0 additions & 1 deletion graphene_mongo/converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import graphene
import mongoengine
import uuid

from graphene.types.json import JSONString
from graphene.utils.str_converters import to_snake_case, to_camel_case
Expand Down
12 changes: 5 additions & 7 deletions graphene_mongo/fields.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from __future__ import absolute_import

import logging
from collections import OrderedDict
from functools import partial, reduce

Expand Down Expand Up @@ -515,11 +516,8 @@ def chained_resolver(self, resolver, is_partial, root, info, **args):
args.update(resolved._query)
args_copy = args.copy()
for arg_name, arg in args.copy().items():
if "." in arg_name or arg_name not in (
self.model._fields_ordered +
('first', 'last', 'before', 'after') +
tuple(self.filter_args.keys())
):
if "." in arg_name or arg_name not in self.model._fields_ordered \
+ ('first', 'last', 'before', 'after') + tuple(self.filter_args.keys()):
args_copy.pop(arg_name)
if arg_name == '_id' and isinstance(arg, dict):
operation = list(arg.keys())[0]
Expand Down Expand Up @@ -554,8 +552,8 @@ def connection_resolver(cls, resolver, connection_type, root, info, **args):
if value:
try:
setattr(root, key, from_global_id(value)[1])
except Exception:
pass
except Exception as error:
logging.error("Exception Occurred: ", exc_info=error)
iterable = resolver(root, info, **args)

if isinstance(connection_type, graphene.NonNull):
Expand Down
2 changes: 1 addition & 1 deletion graphene_mongo/tests/test_converter.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import graphene
import mongoengine
from py.test import raises
from pytest import raises

from .models import (
Article,
Expand Down
2 changes: 1 addition & 1 deletion graphene_mongo/tests/test_types.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from py.test import raises
from pytest import raises

from graphene import Field, Int, Interface, ObjectType
from graphene.relay import Node, is_node
Expand Down
1,252 changes: 1,252 additions & 0 deletions poetry.lock

Large diffs are not rendered by default.

47 changes: 47 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
[tool.poetry]
name = "graphene-mongo"
packages = [{ include = "graphene_mongo" }]
version = "0.3.0"
description = "Graphene Mongoengine integration"
authors = [
"Abaw Chen <abaw.chen@gmail.com>",
]
license = "MIT"
readme = "README.md"
homepage = "https://github.com/graphql-python/graphene-mongo"
repository = "https://github.com/graphql-python/graphene-mongo"
classifiers = [
"Development Status :: 4 - Beta",
"Intended Audience :: Developers",
"Topic :: Software Development :: Libraries",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: Implementation :: PyPy",
"License :: OSI Approved :: MIT License",
]
keywords = [
"graphene-mongo", "graphql", "api", "graphql", "protocol", "relay", "graphene", "mongo", "mongoengine"
]

[tool.poetry.dependencies]
python = ">=3.7,<4"
graphene = ">=3.1.1"
promise = ">=2.3"
mongoengine = ">=0.27"
singledispatch = ">=3.7.0"
iso8601 = "*"

[tool.poetry.group.dev.dependencies]
pytest = "*"
mongomock = ">=4.1.2"
mock = ">=5.0.1"
flake8 = "*"
pytest-cov = "*"
coveralls = "*"
twine = "*"


[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
19 changes: 0 additions & 19 deletions requirements.txt

This file was deleted.

35 changes: 0 additions & 35 deletions setup.py

This file was deleted.

0 comments on commit 40ee17b

Please sign in to comment.