Giter VIP home page Giter VIP logo

urlpath's Introduction

urlpath's People

Contributors

brandonschabell avatar chrono-meter avatar jmcs avatar kajbaf avatar zevisert avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

urlpath's Issues

Python3.12 compatibility

Python3.12 removed _Flavour and _PosixFlavour from pathlib.

import pathlib

ImportError: cannot import name '_PosixFlavour' from 'pathlib'

Add relative_to method

That would be nice to have a relative_to method for URL that would not catch the PurePath.relative_to method.

An implementation:

ralative_path = Path(base_url.path).relative_to(Path(child_path.path))

I'll try to take some time one day to help you for this nice package.

white spaces encoded as '%20' are being converted to '%2520'

I have a url in string that has white spaces enconded as '%20'.
url = 'https://somepath.com/test/Test%20path/my%20test%20file.txt'

when I pass it to URL I get the following:

>>> from urlpath import URL
>>> URL("https://somepath.com/test/Test%20path/my%20test%20file.txt")
URL('https://somepath.com/test/Test%2520path/my%20test%20file.txt')

apparently only happens when the spaces are in the midle of the path.

URL class not recognised by static type checkers

The urlpath.URL class for some reason is being classified as type Any by mypy and hence not being checked properly. I thought this might be a mypy bug, but the same issue occurs with pytype as well.

Minimal example to demonstrate:

from pathlib import Path

from urlpath import URL

def do_something(path: Path, url: URL) -> str:

    return url / path

do_something(Path('file.ext'), URL('example.com')) # ok
do_something('file.ext', URL('example.com')) # error
do_something(Path('file.ext'), 'example.com') # ok ?!?

reveal_type(Path('file.ext')) # Revealed type is pathlib.Path
reveal_type(URL('example.com')) # Revealed type is "Any" ?!?

Any idea why this is? I just found this library today, already use pathlib a lot in my project and really like the look of this, but this behaviour is wierd and makes it less usable in a type hinted enviroment.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.