Code Monkey home page Code Monkey logo

Comments (4)

thentgesMindee avatar thentgesMindee commented on June 15, 2024 1

Alright, looking at the code, I think there might be an issue in the code:
in extension.py, here is the line in charge of loading this env var (C.DEFAULT_LIMITS being "RATELIMIT_DEFAULT")

conf_limits: Optional[StrOrCallableStr] = self.get_app_config(
    C.DEFAULT_LIMITS, None
)

When looking at the code for get_app_config:

def get_app_config(self, key: str, default_value: T = None) -> T:
    """
    Place holder until we find a better way to load config from app
    """
    return self.app_config(key, default=default_value, cast=type(default_value))

It means, it will try to cast any limit to None since None is the default value, hence your error Not a valid NoneType.

An alternative, without having to fix the code if your change is urgent, would be to use a different environment variable, and pass it manually with default_limits kwargs when initializing your Limiter instance.

from slowapi.

thentgesMindee avatar thentgesMindee commented on June 15, 2024

Hi, did you try '["12/10seconds"]' ? this is the output of json.dumps(["12/10seconds"]), guess it might work (didn't try it, sorry)

from slowapi.

Alurith avatar Alurith commented on June 15, 2024

Hi @thentgesMindee I tried as you said RATELIMIT_DEFAULT='["12/10seconds"]' but didn't work.

from slowapi.

thentgesMindee avatar thentgesMindee commented on June 15, 2024

Also, this made me see this the comment Place holder until we find a better way to load config from app, @laurentS maybe we could use pydantic's BaseSettings class to defer this config loading logic to a library specialized on that ? (Might not be the right place to start this discussion, feel free to move it somewhere else)

from slowapi.

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.