Giter Club home page Giter Club logo

Comments (10)

bauerji avatar bauerji commented on May 22, 2024 2

@yasinyildiza @CharmingZhou

this issue should not occur anymore since release 0.6.1

Feel free to reopen or create new issue if the problem persists.

Jirka

from flask-pydantic.

bauerji avatar bauerji commented on May 22, 2024

Hello,

this is interesting. When I add your code into the example app provided in the repository it works fine.

Could you post your whole code? Also in your requirements there is flask-pydantic-spec==0.1.3 and no flask-pydantic. Maybe there could be some kind of interference with these two libraries.

Jirka

from flask-pydantic.

CharmingZhou avatar CharmingZhou commented on May 22, 2024

sorry,flask-pydantic-spec==0.1.3 is other test library. Right requirement is Flask-Pydantic==0.4.0

from flask-pydantic.

bauerji avatar bauerji commented on May 22, 2024

I am not able to reproduce your problem. Could you please share a whole minimal example that still produces the error?

from flask-pydantic.

CharmingZhou avatar CharmingZhou commented on May 22, 2024

I am not able to reproduce your problem. Could you please share a whole minimal example that still produces the error?
Here is a minimal example:

from flask import Flask
from flask import Blueprint

app = Flask(__name__)

from pydantic import BaseModel
from flask_pydantic import validate
from typing import List
class Query(BaseModel):
    query: str
    
test_bp = Blueprint("test",__name__)
@test_bp.route("/test_route", methods=["GET"])
@validate(query=Query)
def test_route(query:Query):
    return {}

if __name__ == "__main__":
    app.register_blueprint(test_bp)
    app.run(host="0.0.0.0", port="8888")

from flask-pydantic.

yasinyildiza avatar yasinyildiza commented on May 22, 2024

Same thing happened to me.

With a little investigation, I think, I found the root cause.

In convert_query_params, this line

    return {
        **query_params,

should be

    return {
        **query_params.to_dict(flat=True), # flat=True is the default

because when request.args is unpacked, dict values become list rather than str; in other words, explicit cast is done with to_dict(flat=False).

from flask-pydantic.

bauerji avatar bauerji commented on May 22, 2024

I am sorry guys, I am running the exact same code as @CharmingZhou posted and still no error (tried both python 3.6 and 3.9). Could You please @yasinyildiza share your minimal example together with your environment setup?

from flask-pydantic.

yasinyildiza avatar yasinyildiza commented on May 22, 2024

@bauerji

Python
3.6.2

pip freeze

click==7.1.2
dataclasses==0.8
Flask==1.1.2
Flask-Pydantic==0.6.0
itsdangerous==1.1.0
Jinja2==2.11.3
MarkupSafe==1.1.1
pydantic==1.7.3
Werkzeug==1.0.1

code

import flask
import flask_pydantic
import pydantic


class Query(pydantic.BaseModel):
    query: str


app = flask.Flask(__name__)


@app.route('/test')
@flask_pydantic.validate(query=Query)
def test(query:Query):
    return flask.jsonify({'query': query.dict()})


if __name__ == '__main__':
    app.run(port=5000, debug=True)

I also tried to run the tests after setting up the dev environment (following Contributing instructions). This is the result:

18 failed, 55 passed, 1 warning

from flask-pydantic.

bauerji avatar bauerji commented on May 22, 2024

@yasinyildiza @CharmingZhou
It seems that there is a problem with specifically python 3.6.2 version. Unfortunately github won't let me to run tests in github actions using this version see this.

I will try to solve this issue, however I would recommend You to upgrade to at least the newest 3.6 version (3.6.13 at the moment).

from flask-pydantic.

yasinyildiza avatar yasinyildiza commented on May 22, 2024

I tested with 0.6.1, and it is working very well.
Thanks a lot @bauerji

from flask-pydantic.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.