code: def from_url(cls, url: URL,
                   *, encoding: str='latin1') -> Optional['BasicAuth']:
          
          if not isinstance(url, URL):
              raise TypeError("url should be yarl.URL instance")
          if url.user is None:
              return None
          return cls(url.user, url.password or '', encoding=encoding)
docs: Create BasicAuth from url.