# Buggy code
def get_package_from_url(cls, url):  # type: (str) -> Package
    with temporary_directory() as temp_dir:
        temp_dir = Path(temp_dir)
        file_name = os.path.basename(urlparse.urlparse(url).path)
        download_file(url, temp_dir / file_name)

        package = cls.get_package_from_file(temp_dir / file_name)

    package._source_type = "url"
    package._source_url = url

    return package


# Traceback (TypeError)
TypeError

invalid file: PosixPath('/tmp/tmplltfjswb/beautifulsoup4-4.9.1-py3-none-any.whl')

Traceback (most recent call last):
File "/home/mike.nerone/myapp/.tox/.poetry/lib/python3.5/site-packages/clikit/console_application.py", line 131, in run
status_code = command.handle(parsed_args, io)
File "/home/mike.nerone/myapp/.tox/.poetry/lib/python3.5/site-packages/clikit/api/command/command.py", line 120, in handle
status_code = self._do_handle(args, io)
File "/home/mike.nerone/myapp/.tox/.poetry/lib/python3.5/site-packages/clikit/api/command/command.py", line 171, in _do_handle
return getattr(handler, handler_method)(args, io, self)
File "/home/mike.nerone/myapp/.tox/.poetry/lib/python3.5/site-packages/cleo/commands/command.py", line 92, in wrap_handle
return self.handle()
File "/home/mike.nerone/myapp/.tox/.poetry/lib/python3.5/site-packages/poetry/console/commands/lock.py", line 26, in handle
return self._installer.run()
File "/home/mike.nerone/myapp/.tox/.poetry/lib/python3.5/site-packages/poetry/installation/installer.py", line 99, in run
return self._do_install(local_repo)
File "/home/mike.nerone/myapp/.tox/.poetry/lib/python3.5/site-packages/poetry/installation/installer.py", line 205, in _do_install
ops = solver.solve(use_latest=self._whitelist)
File "/home/mike.nerone/myapp/.tox/.poetry/lib/python3.5/site-packages/poetry/puzzle/solver.py", line 65, in solve
packages, depths = self._solve(use_latest=use_latest)
File "/home/mike.nerone/myapp/.tox/.poetry/lib/python3.5/site-packages/poetry/puzzle/solver.py", line 215, in _solve
self._package, self._provider, locked=locked, use_latest=use_latest
File "/home/mike.nerone/myapp/.tox/.poetry/lib/python3.5/site-packages/poetry/mixology/__init__.py", line 7, in resolve_version
return solver.solve()
File "/home/mike.nerone/myapp/.tox/.poetry/lib/python3.5/site-packages/poetry/mixology/version_solver.py", line 84, in solve
next = self._choose_package_version()
File "/home/mike.nerone/myapp/.tox/.poetry/lib/python3.5/site-packages/poetry/mixology/version_solver.py", line 392, in _choose_package_version
version = self._provider.complete_package(version)
File "/home/mike.nerone/myapp/.tox/.poetry/lib/python3.5/site-packages/poetry/puzzle/provider.py", line 481, in complete_package
self.search_for_url(r)
File "/home/mike.nerone/myapp/.tox/.poetry/lib/python3.5/site-packages/poetry/puzzle/provider.py", line 332, in search_for_url
package = self.get_package_from_url(dependency.url)
File "/home/mike.nerone/myapp/.tox/.poetry/lib/python3.5/site-packages/poetry/puzzle/provider.py", line 361, in get_package_from_url
download_file(url, temp_dir / file_name)
File "/home/mike.nerone/myapp/.tox/.poetry/lib/python3.5/site-packages/poetry/utils/helpers.py", line 99, in download_file
with open(dest, "wb") as f:

# Fixed code
def get_package_from_url(cls, url):  # type: (str) -> Package
    with temporary_directory() as temp_dir:
        temp_dir = Path(temp_dir)
        file_name = os.path.basename(urlparse.urlparse(url).path)
        download_file(url, str(temp_dir / file_name))

        package = cls.get_package_from_file(temp_dir / file_name)

    package._source_type = "url"
    package._source_url = url

    return package