question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[FEATURE] Descriptive representational strings for params

See original GitHub issue

Is your feature request related to a problem

Kind of, recently I generated a documentation for one of my personal projects using mkdocstrings and that’s how it renders params:

That’s the behavior I would prefer:

The solution you would like

Implement __repr__ for all classes in fastapi.params. I am willing to do that, but first I wanted to make sure that this is a good idea and such PR would be accepted.

Describe alternatives you’ve considered

A dirty hack like this:

from fastapi.params import Depends as Dep

class Depends(Dep):

    def __init__(self, dependency = None, *, use_cache=True):
        super().__init__(dependency, use_cache=True)

    def __repr__(self) -> str:
        name = getattr(self.dependency, "__name__", type(self.dependency).__name__)
        args = name
        if not self.use_cache:
            args += ", use_cache=False"
        return f"Depends({args})"

Works, but it would be nice to have it by default.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:4
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

3reactions
tiangolocommented, Jun 9, 2020

Yep, there’s no PR with this yet, so if @victorphoenix3 or @rkbeatss are ready, go ahead! 🚀 🤓

1reaction
jupedcommented, Jun 9, 2020

I think this would be a good issue for @victorphoenix3 and @rkbeatss to work on - I don’t want to “steal” it out from under @fabrizzioalco if he’s already started, though.

Read more comments on GitHub >

github_iconTop Results From Across the Web

String functions for Bicep - Azure Resource Manager
Returns the base64 representation of the input string. Namespace: sys. Parameters. Parameter, Required, Type, Description. inputString, Yes ...
Read more >
REST API Best Practices for Parameter and Query String Usage
How to use Query String Parameters? Array and Map Parameters; When Should the Query String not be Used? Introduction. Representational State ...
Read more >
class StringParameter (construct) · AWS CDK
Returns a string representation of this construct. static fromSecureStringParameterAttributes(scope, id, attrs), Imports a secure string parameter from the SSM ...
Read more >
Parameter Sets - PBR Book
Most of pbrt's API routines take a ParamSet as one of their parameters; ... of parameters to any function, so a more time-efficient...
Read more >
String-Based Feature Representation for Trajectory Clustering
A string-based model is used, where trajectories are represented as strings and string-based distance metrics are used to measure the similarity between ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found