@@ -253,7 +253,9 @@ class SchemaValidator:
253253 `None` if the schema has no default value, otherwise a [`Some`][pydantic_core.Some] containing the default.
254254 """
255255
256- _IncEx : TypeAlias = set [int ] | set [str ] | Mapping [int , _IncEx | Literal [True ]] | Mapping [str , _IncEx | Literal [True ]]
256+ # In reality, `bool` should be replaced by `Literal[True]` but mypy fails to correctly apply bidirectional type inference
257+ # (e.g. when using `{'a': {'b': True}}`).
258+ _IncEx : TypeAlias = set [int ] | set [str ] | Mapping [int , _IncEx | bool ] | Mapping [str , _IncEx | bool ]
257259
258260@final
259261class SchemaSerializer :
@@ -492,104 +494,29 @@ class Url(SupportsAllComparisons):
492494 by Mozilla.
493495 """
494496
495- def __init__ (self , url : str ) -> None :
496- """Initializes the `Url`.
497-
498- Args:
499- url: String representation of a URL.
500-
501- Returns:
502- A new `Url` instance.
503-
504- Raises:
505- ValidationError: If the URL is invalid.
506- """
507-
497+ def __init__ (self , url : str ) -> None : ...
508498 def __new__ (cls , url : str ) -> Self : ...
509499 @property
510- def scheme (self ) -> str :
511- """
512- The scheme part of the URL.
513-
514- e.g. `https` in `https://user:pass@host:port/path?query#fragment`
515- """
500+ def scheme (self ) -> str : ...
516501 @property
517- def username (self ) -> str | None :
518- """
519- The username part of the URL, or `None`.
520-
521- e.g. `user` in `https://user:pass@host:port/path?query#fragment`
522- """
502+ def username (self ) -> str | None : ...
523503 @property
524- def password (self ) -> str | None :
525- """
526- The password part of the URL, or `None`.
527-
528- e.g. `pass` in `https://user:pass@host:port/path?query#fragment`
529- """
504+ def password (self ) -> str | None : ...
530505 @property
531- def host (self ) -> str | None :
532- """
533- The host part of the URL, or `None`.
534-
535- If the URL must be punycode encoded, this is the encoded host, e.g if the input URL is `https://£££.com`,
536- `host` will be `xn--9aaa.com`
537- """
538- def unicode_host (self ) -> str | None :
539- """
540- The host part of the URL as a unicode string, or `None`.
541-
542- e.g. `host` in `https://user:pass@host:port/path?query#fragment`
543-
544- If the URL must be punycode encoded, this is the decoded host, e.g if the input URL is `https://£££.com`,
545- `unicode_host()` will be `£££.com`
546- """
506+ def host (self ) -> str | None : ...
507+ def unicode_host (self ) -> str | None : ...
547508 @property
548- def port (self ) -> int | None :
549- """
550- The port part of the URL, or `None`.
551-
552- e.g. `port` in `https://user:pass@host:port/path?query#fragment`
553- """
509+ def port (self ) -> int | None : ...
554510 @property
555- def path (self ) -> str | None :
556- """
557- The path part of the URL, or `None`.
558-
559- e.g. `/path` in `https://user:pass@host:port/path?query#fragment`
560- """
511+ def path (self ) -> str | None : ...
561512 @property
562- def query (self ) -> str | None :
563- """
564- The query part of the URL, or `None`.
565-
566- e.g. `query` in `https://user:pass@host:port/path?query#fragment`
567- """
568- def query_params (self ) -> list [tuple [str , str ]]:
569- """
570- The query part of the URL as a list of key-value pairs.
571-
572- e.g. `[('foo', 'bar')]` in `https://user:pass@host:port/path?foo=bar#fragment`
573- """
513+ def query (self ) -> str | None : ...
514+ def query_params (self ) -> list [tuple [str , str ]]: ...
574515 @property
575- def fragment (self ) -> str | None :
576- """
577- The fragment part of the URL, or `None`.
578-
579- e.g. `fragment` in `https://user:pass@host:port/path?query#fragment`
580- """
581- def unicode_string (self ) -> str :
582- """
583- The URL as a unicode string, unlike `__str__()` this will not punycode encode the host.
584-
585- If the URL must be punycode encoded, this is the decoded string, e.g if the input URL is `https://£££.com`,
586- `unicode_string()` will be `https://£££.com`
587- """
516+ def fragment (self ) -> str | None : ...
517+ def unicode_string (self ) -> str : ...
588518 def __repr__ (self ) -> str : ...
589- def __str__ (self ) -> str :
590- """
591- The URL as a string, this will punycode encode the host if required.
592- """
519+ def __str__ (self ) -> str : ...
593520 def __deepcopy__ (self , memo : dict ) -> str : ...
594521 @classmethod
595522 def build (
@@ -603,23 +530,7 @@ class Url(SupportsAllComparisons):
603530 path : str | None = None ,
604531 query : str | None = None ,
605532 fragment : str | None = None ,
606- ) -> Self :
607- """
608- Build a new `Url` instance from its component parts.
609-
610- Args:
611- scheme: The scheme part of the URL.
612- username: The username part of the URL, or omit for no username.
613- password: The password part of the URL, or omit for no password.
614- host: The host part of the URL.
615- port: The port part of the URL, or omit for no port.
616- path: The path part of the URL, or omit for no path.
617- query: The query part of the URL, or omit for no query.
618- fragment: The fragment part of the URL, or omit for no fragment.
619-
620- Returns:
621- An instance of URL
622- """
533+ ) -> Self : ...
623534
624535class MultiHostUrl (SupportsAllComparisons ):
625536 """
@@ -629,82 +540,21 @@ class MultiHostUrl(SupportsAllComparisons):
629540 by Mozilla.
630541 """
631542
632- def __init__ (self , url : str ) -> None :
633- """Initializes the `MultiHostUrl`.
634-
635- Args:
636- url: String representation of a URL.
637-
638- Returns:
639- A new `MultiHostUrl` instance.
640-
641- Raises:
642- ValidationError: If the URL is invalid.
643- """
644-
543+ def __init__ (self , url : str ) -> None : ...
645544 def __new__ (cls , url : str ) -> Self : ...
646545 @property
647- def scheme (self ) -> str :
648- """
649- The scheme part of the URL.
650-
651- e.g. `https` in `https://foo.com,bar.com/path?query#fragment`
652- """
546+ def scheme (self ) -> str : ...
653547 @property
654- def path (self ) -> str | None :
655- """
656- The path part of the URL, or `None`.
657-
658- e.g. `/path` in `https://foo.com,bar.com/path?query#fragment`
659- """
548+ def path (self ) -> str | None : ...
660549 @property
661- def query (self ) -> str | None :
662- """
663- The query part of the URL, or `None`.
664-
665- e.g. `query` in `https://foo.com,bar.com/path?query#fragment`
666- """
667- def query_params (self ) -> list [tuple [str , str ]]:
668- """
669- The query part of the URL as a list of key-value pairs.
670-
671- e.g. `[('foo', 'bar')]` in `https://foo.com,bar.com/path?query#fragment`
672- """
550+ def query (self ) -> str | None : ...
551+ def query_params (self ) -> list [tuple [str , str ]]: ...
673552 @property
674- def fragment (self ) -> str | None :
675- """
676- The fragment part of the URL, or `None`.
677-
678- e.g. `fragment` in `https://foo.com,bar.com/path?query#fragment`
679- """
680- def hosts (self ) -> list [MultiHostHost ]:
681- '''
682-
683- The hosts of the `MultiHostUrl` as [`MultiHostHost`][pydantic_core.MultiHostHost] typed dicts.
684-
685- ```py
686- from pydantic_core import MultiHostUrl
687-
688- mhu = MultiHostUrl('https://foo.com:123,foo:[email protected] /path') 689- print(mhu.hosts())
690- """
691- [
692- {'username': None, 'password': None, 'host': 'foo.com', 'port': 123},
693- {'username': 'foo', 'password': 'bar', 'host': 'bar.com', 'port': 443}
694- ]
695- ```
696- Returns:
697- A list of dicts, each representing a host.
698- '''
699- def unicode_string (self ) -> str :
700- """
701- The URL as a unicode string, unlike `__str__()` this will not punycode encode the hosts.
702- """
553+ def fragment (self ) -> str | None : ...
554+ def hosts (self ) -> list [MultiHostHost ]: ...
555+ def unicode_string (self ) -> str : ...
703556 def __repr__ (self ) -> str : ...
704- def __str__ (self ) -> str :
705- """
706- The URL as a string, this will punycode encode the hosts if required.
707- """
557+ def __str__ (self ) -> str : ...
708558 def __deepcopy__ (self , memo : dict ) -> Self : ...
709559 @classmethod
710560 def build (
@@ -719,27 +569,7 @@ class MultiHostUrl(SupportsAllComparisons):
719569 path : str | None = None ,
720570 query : str | None = None ,
721571 fragment : str | None = None ,
722- ) -> Self :
723- """
724- Build a new `MultiHostUrl` instance from its component parts.
725-
726- This method takes either `hosts` - a list of `MultiHostHost` typed dicts, or the individual components
727- `username`, `password`, `host` and `port`.
728-
729- Args:
730- scheme: The scheme part of the URL.
731- hosts: Multiple hosts to build the URL from.
732- username: The username part of the URL.
733- password: The password part of the URL.
734- host: The host part of the URL.
735- port: The port part of the URL.
736- path: The path part of the URL.
737- query: The query part of the URL, or omit for no query.
738- fragment: The fragment part of the URL, or omit for no fragment.
739-
740- Returns:
741- An instance of `MultiHostUrl`
742- """
572+ ) -> Self : ...
743573
744574@final
745575class SchemaError (Exception ):
0 commit comments