-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added safe mode option and url builder #23
Conversation
None instead. | ||
""" | ||
return get_current_context(silent=True) | ||
return context.obj.get("DEBUG") if (context := get_current_context(silent=True)) else False |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This pattern of adding an object to the context and fetching it this way is repeated (and will be repeated again if the submit dry-run is ever fully implemented).
Maybe add a new util? JokesContext
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Context can already be fetched from anywhere in the code via get_current_context
.
We could add a method like this though:
def get_context_object(key: str, default: bool = False) -> bool:
return c.obj.get(key) if (c := get_current_context(silent=True)) else default
src/jokes/utils/urls.py
Outdated
SUBMIT = "submit" | ||
|
||
|
||
def format_params(dict: Mapping[str, Primitive]) -> str: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Passing params here and then calling the dict()
method internally is possible, but it doesn't ensure the safety of the join, specifically the f"{k}={v}"
since the pydantic dict method only requires a dict[str, Any]
.
So theoretically we could construct a parameter class that returns a dict of type dict[str, SomeComplexType]
which would either break the query string or return something illegible.
closes #22