Skip to content
This repository has been archived by the owner on Dec 13, 2022. It is now read-only.

Commit

Permalink
Fix mypy and flake8 errors and bump version to 2.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
mostafa committed Mar 8, 2021
1 parent edcda04 commit 140c693
Show file tree
Hide file tree
Showing 15 changed files with 31 additions and 24 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ jobs:
python setup.py -q install
- name: Check types and syntax 🦆
run: |
mypy .
flake8
mypy --exclude 'build/*' .
flake8 --exclude 'build/*' .
- name: Test 🧪
env:
DB_URL: bolt://neo4j:ci@localhost:7687
Expand Down
Empty file.
7 changes: 4 additions & 3 deletions bin/template/{{cookiecutter.app_name}}/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@

import os

DEBUG = os.getenv("DEBUG", {{cookiecutter.DEBUG}})
DEBUG = bool(os.getenv("DEBUG", {{cookiecutter.DEBUG}})) # type: ignore # noqa

IP_ADDRESS = os.getenv("IP_ADDRESS", "{{cookiecutter.IP_ADDRESS}}")
PORT = os.getenv("PORT", {{cookiecutter.PORT}})
PORT = int(os.getenv("PORT", {{cookiecutter.PORT}})) # type: ignore # noqa

VERSION = os.getenv("VERSION", "0.0.1")
SECRET_KEY = os.getenv("SECRET_KEY", "{{cookiecutter.SECRET_KEY}}")
DB_URL = os.getenv(
"DB_URL", "bolt://{{cookiecutter.NEO4J_USERNAME}}:{{cookiecutter.NEO4J_PASSWORD}}@{{cookiecutter.NEO4J_HOSTNAME}}:{{cookiecutter.NEO4J_BOLT_PORT}}")
"DB_URL", ("bolt://{{cookiecutter.NEO4J_USERNAME}}:{{cookiecutter.NEO4J_PASSWORD}}@"
"{{cookiecutter.NEO4J_HOSTNAME}}:{{cookiecutter.NEO4J_BOLT_PORT}}"))

X_AUTH_TOKEN = "{{cookiecutter.X_AUTH_TOKEN}}"
ENABLE_DELETE_ALL = os.getenv(
Expand Down
2 changes: 1 addition & 1 deletion bin/template/{{cookiecutter.app_name}}/main.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-

import config
import neomodel
import neomodel # type: ignore
from flask import Flask
from users import UsersView

Expand Down
4 changes: 2 additions & 2 deletions bin/template/{{cookiecutter.app_name}}/schema.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-

from neomodel import StringProperty, StructuredNode, UniqueIdProperty
from webargs import fields
from neomodel import StringProperty, StructuredNode, UniqueIdProperty # type: ignore
from webargs import fields # type: ignore

from grest import models

Expand Down
Empty file removed docs/__init__.py
Empty file.
5 changes: 3 additions & 2 deletions examples/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
from neomodel import StringProperty, StructuredNode, UniqueIdProperty
from webargs import fields # type: ignore

from grest import GRest, global_config, models, utils
from grest import GRest, global_config, models


# noinspection PyAbstractClass
Expand Down Expand Up @@ -64,7 +64,8 @@ def index():

if global_config.LOG_ENABLED:
logging.basicConfig(filename=os.path.abspath(os.path.join(
global_config.LOG_LOCATION, global_config.LOG_FILENAME)), format=global_config.LOG_FORMAT)
global_config.LOG_LOCATION, global_config.LOG_FILENAME)),
format=global_config.LOG_FORMAT)
app.ext_logger = logging.getLogger()
app.ext_logger.setLevel(global_config.LOG_LEVEL)
handler = logging.handlers.RotatingFileHandler(
Expand Down
7 changes: 4 additions & 3 deletions examples/extended_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
UniqueIdProperty)
from webargs import fields # type: ignore

from grest import GRest, global_config, models, utils
from grest import GRest, global_config, models


class PetInfo(StructuredRel, models.Relation):
Expand Down Expand Up @@ -98,7 +98,7 @@ def owner(self, pet_id):
return jsonify(errors=["Selected pet has not been adopted yet!"]), 404
else:
return jsonify(errors=["Selected pet does not exists!"]), 404
except:
except Exception:
return jsonify(errors=["An error occurred while processing your request."]), 500


Expand All @@ -115,7 +115,8 @@ def index():

if (global_config.LOG_ENABLED):
logging.basicConfig(filename=os.path.abspath(os.path.join(
global_config.LOG_LOCATION, global_config.LOG_FILENAME)), format=global_config.LOG_FORMAT)
global_config.LOG_LOCATION, global_config.LOG_FILENAME)),
format=global_config.LOG_FORMAT)
app.ext_logger = logging.getLogger()
app.ext_logger.setLevel(global_config.LOG_LEVEL)
handler = logging.handlers.RotatingFileHandler(
Expand Down
2 changes: 1 addition & 1 deletion grest/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@

from .grest import GRest, GRestResponse # noqa

__version__ = '2.1.0'
__version__ = '2.2.0'
4 changes: 2 additions & 2 deletions grest/verbs/delete.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@

from flask_classful import FlaskView # type: ignore
from neomodel import db # type: ignore
from neomodel.exceptions import (DoesNotExist, # type: ignore
RequiredProperty, UniqueProperty)
from neomodel.exceptions import DoesNotExist # type: ignore
from neomodel.exceptions import RequiredProperty, UniqueProperty

import grest
import grest.messages as msg
Expand Down
4 changes: 2 additions & 2 deletions grest/verbs/post.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
from flask import request
from flask_classful import FlaskView # type: ignore
from neomodel import db # type: ignore
from neomodel.exceptions import (DoesNotExist, # type: ignore
RequiredProperty, UniqueProperty)
from neomodel.exceptions import DoesNotExist # type: ignore
from neomodel.exceptions import RequiredProperty, UniqueProperty

import grest
import grest.messages as msg
Expand Down
4 changes: 2 additions & 2 deletions grest/verbs/put.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
from flask import Request
from flask_classful import FlaskView # type: ignore
from neomodel import db # type: ignore
from neomodel.exceptions import (DoesNotExist, # type: ignore
RequiredProperty, UniqueProperty)
from neomodel.exceptions import DoesNotExist # type: ignore
from neomodel.exceptions import RequiredProperty, UniqueProperty

import grest
import grest.messages as msg
Expand Down
1 change: 0 additions & 1 deletion tests/test_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
#

import json
import os

import pytest
from flask import url_for
Expand Down
6 changes: 4 additions & 2 deletions tests/test_extended_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,10 @@ def test_api_post_user(client):
global uid
res = client.post("/users",
data=json.dumps(
{"first_name": "test1", "last_name": "test2",
"phone_number": "123", "secret_field": "MY_SECRET"}),
{"first_name": "test1",
"last_name": "test2",
"phone_number": "123",
"secret_field": "MY_SECRET"}),
headers={"Content-Type": "application/json"})
assert res.status_code == 200
if ("uid" in res.json):
Expand Down
5 changes: 4 additions & 1 deletion tests/test_validation_rules_property.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@
# along with grest. If not, see <http://www.gnu.org/licenses/>.
#

from neomodel import * # type: ignore
from neomodel import (ArrayProperty, BooleanProperty, DateProperty, # type: ignore
DateTimeProperty, EmailProperty, IntegerProperty,
JSONProperty, StringProperty, StructuredNode,
UniqueIdProperty)
from webargs import fields as webargs_fields # type: ignore

import grest
Expand Down

0 comments on commit 140c693

Please sign in to comment.