Giter Club home page Giter Club logo

Comments (8)

tomchristie avatar tomchristie commented on August 24, 2024 2

If we do keep it as a URL instance, then one option to keep closer API compat would be to allow string comparisons, eg URL(“https://www.encode.io/“) == “https://www.encode.io/“

That has the advantage of being string-like, and far less likely to introduce any API breakage.

from httpx.

tomchristie avatar tomchristie commented on August 24, 2024 1

Seems like it's probably the best all round option yeah.

from httpx.

sethmlarson avatar sethmlarson commented on August 24, 2024

I'm for allowing string comparisons and providing the read-only URL instance. :) Seems like something users are probably doing themselves and shouldn't have to.

from httpx.

graingert avatar graingert commented on August 24, 2024

how about:

with http3.Session(requests_compat=True) as s:
    assert type(s.get("https://example.com").url) is str

from httpx.

sethmlarson avatar sethmlarson commented on August 24, 2024

I'd say that flags / parameters that massively alter the behavior of a function should probably be avoided.
Typically what a lot of URL instance classes do to recover the original string for the URL is provide an .unsplit() method.

from httpx.

graingert avatar graingert commented on August 24, 2024

How about instead of maintaining backwards compatibility with requests, provide a series of codemods so people can upgrade their code to the new api?

from httpx.

sethmlarson avatar sethmlarson commented on August 24, 2024

We'll definitely need a section in the documentation on migration strategy, especially from requests but also useful to how for instance urllib3 does something compared to http3.

from httpx.

StephenBrown2 avatar StephenBrown2 commented on August 24, 2024

Personally I am quite in favor of the URL class, and am currently using urlpath for approximately the same function, including the ability to concatenate parts with /. Making URL instances string comparable (and bonus: / concat-able!) would be the best option I think, giving the best of both worlds.

from httpx.

Related Issues (20)

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.