Re: [libvirt PATCH v2 4/6] ci: Introduce a util module

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Mar 17, 2021 at 05:06:33PM +0100, Andrea Bolognani wrote:
> On Tue, 2021-03-16 at 18:32 +0100, Erik Skultety wrote:
> > +++ b/ci/util.py
> > +def get_registry_images(uri: str) -> Dict[str, str]:
> 
> On closer inspection, the return type is not correct: we return a
> list of JSON objects, not a mapping from strings to strings.

Good catch.

> 
> I don't know how to express that in terms of Python types
> (List[Dict[str, Any]]?), and I'm concerned by the fact that changing
> the return type to something obviously wrong like "int" results in
> zero observable changes.

I'd suggest List[Dict] to be enough in this case since. We can safely assume
the returned JSON will always be a list of objects, the rest is on the caller.

> 
> How are type hints enforced? Do we need to turn that on somehow?

They're not. Python will always remain a dynamically typed language. The whole
point of type hinting is for static analysis via 'mypy' and for various IDEs
that can actually make use of those as well during completion which is nice.
(I'm wondering whether the jedi vim plugin is capable of reading those too)

Erik




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux