# Buggy code
def pull(self, repository, tag=None, **kwargs):
    """
    Pull an image of the given name and return it. Similar to the
    ``docker pull`` command.
    If no tag is specified, all tags from that repository will be
    pulled.

    If you want to get the raw pull output, use the
    :py:meth:`~docker.api.image.ImageApiMixin.pull` method in the
    low-level API.

    Args:
        name (str): The repository to pull
        tag (str): The tag to pull
        auth_config (dict): Override the credentials that
            :py:meth:`~docker.client.DockerClient.login` has set for
            this request. ``auth_config`` should contain the ``username``
            and ``password`` keys to be valid.
        platform (str): Platform in the format ``os[/arch[/variant]]``

    Returns:
        (:py:class:`Image` or list): The image that has been pulled.
            If no ``tag`` was specified, the method will return a list
            of :py:class:`Image` objects belonging to this repository.

    Raises:
        :py:class:`docker.errors.APIError`
            If the server returns an error.

    Example:

        >>> # Pull the image tagged `latest` in the busybox repo
        >>> image = client.images.pull('busybox:latest')

        >>> # Pull all tags in the busybox repo
        >>> images = client.images.pull('busybox')
    """
    if not tag:
        repository, tag = parse_repository_tag(repository)

    self.client.api.pull(repository, tag=tag, **kwargs)
    if tag:
        return self.get("{0}:{1}".format(repository, tag))
    return self.list(repository)


# Traceback (requests.exceptions.HTTPError)
import docker
client = docker.from_env()
client.images.pull('python@sha256:7c3028aa4b9a30a34ce778b1fd4f460c9cdf174515a94641a89ef40c115b51e5')
Traceback (most recent call last):
File "/usr/lib/python3.6/site-packages/docker/api/client.py", line 223, in _raise_for_status
response.raise_for_status()
File "/usr/lib/python3.6/site-packages/requests/models.py", line 935, in raise_for_status
raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 400 Client Error: Bad Request for url: https://192.168.99.100:2376/v1.35/images/python:sha256:7c3028aa4b9a30a34ce778b1fd4f460c9cdf174515a94641a89ef40c115b51e5/json

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python3.6/site-packages/docker/models/images.py", line 311, in pull
return self.get('{0}:{1}'.format(repository, tag))
File "/usr/lib/python3.6/site-packages/docker/models/images.py", line 212, in get
return self.prepare_model(self.client.api.inspect_image(name))
File "/usr/lib/python3.6/site-packages/docker/utils/decorators.py", line 19, in wrapped
return f(self, resource_id, *args, **kwargs)
File "/usr/lib/python3.6/site-packages/docker/api/image.py", line 241, in inspect_image
self._get(self._url("/images/{0}/json", image)), True
File "/usr/lib/python3.6/site-packages/docker/api/client.py", line 229, in _result
self._raise_for_status(response)
File "/usr/lib/python3.6/site-packages/docker/api/client.py", line 225, in _raise_for_status
raise create_api_error_from_http_exception(e)
File "/usr/lib/python3.6/site-packages/docker/errors.py", line 31, in create_api_error_from_http_exception
raise cls(e, response=response, explanation=explanation)
docker.errors.APIError: 400 Client Error: Bad Request ("no such image: python:sha256:7c3028aa4b9a30a34ce778b1fd4f460c9cdf174515a94641a89ef40c115b51e5: invalid reference format")

# Fixed code
def pull(self, repository, tag=None, **kwargs):
    """
    Pull an image of the given name and return it. Similar to the
    ``docker pull`` command.
    If no tag is specified, all tags from that repository will be
    pulled.

    If you want to get the raw pull output, use the
    :py:meth:`~docker.api.image.ImageApiMixin.pull` method in the
    low-level API.

    Args:
        name (str): The repository to pull
        tag (str): The tag to pull
        auth_config (dict): Override the credentials that
            :py:meth:`~docker.client.DockerClient.login` has set for
            this request. ``auth_config`` should contain the ``username``
            and ``password`` keys to be valid.
        platform (str): Platform in the format ``os[/arch[/variant]]``

    Returns:
        (:py:class:`Image` or list): The image that has been pulled.
            If no ``tag`` was specified, the method will return a list
            of :py:class:`Image` objects belonging to this repository.

    Raises:
        :py:class:`docker.errors.APIError`
            If the server returns an error.

    Example:

        >>> # Pull the image tagged `latest` in the busybox repo
        >>> image = client.images.pull('busybox:latest')

        >>> # Pull all tags in the busybox repo
        >>> images = client.images.pull('busybox')
    """
    if not tag:
        repository, tag = parse_repository_tag(repository)

    self.client.api.pull(repository, tag=tag, **kwargs)
    if tag:
        return self.get(
            "{0}{2}{1}".format(
                repository, tag, "@" if tag.startswith("sha256:") else ":"
            )
        )
    return self.list(repository)