Live data from Hacker News

Deprecations via warnings don't work for Python libraries

sethmlarson.dev

21–30 of 93 posts

Re: Deprecations via warnings don't work for Python libraries

#21

I think they are misreading the situation. The devil is in the details. It seems `getHeaders` v. `headers` is non-security, non-performance related issue. Why people should spend time fixing these?

If you (either directly or from SerpApi) are supporting the urllib3 folks (through a Tidelift subscription), then yes, that is a valid point.

Otherwise, I'd say that's a very brave comment you are making.

Re: Deprecations via warnings don't work for Python libraries

#22

Wait, does urlib not use semvar? Don't remove APIs on minor releases people. A major release doesn't have to be a problem or a major redesign, you can do major release 400 for all I care, just don't break things on minor releases. Lots of things not using semvar that I always just assumed did.

This, I think, is the crux of the matter.

As an example, I always knew urllib3 as one of the foundational packages that Requests uses. And I was curious, what versions of urllib3 does Requests pull in?

Well, according to https://github.com/psf/requests/blob/main/setup.cfg, it's this:

    urllib3>=1.21.1,
That is exactly the kind of dependency specification I would expect to see for a package that is using semver: The current version of urllib3 is 2.x, so with semver, you set up your dependencies to avoid the next major-version number (in this case, 3).

So, it seems to me that even the Requests folks assumed urllib3 was using semver.

Re: Deprecations via warnings don't work for Python libraries

#23
post #6

>We ended up adding the APIs back and creating a hurried release to fix the issue. So it was entirely possible to keep the software working with these. Why change/remove them in the first place? Is the benefit of of the new abstraction greater than the downside of requiring everyone using the software to re-write theirs?

OS software maintainers don't like maintaining legacy ugly APIs forever and want to refactor/remove legacy code to keep themselves sane and the project maintainable.

Every public API change is a cost on the user: for an extreme example, if every library I ever used renamed half its APIs every year to align with the latest ontology, then there would hardly be any point in saving my scripts, since I'd have to be constantly rewriting them all.

Of course, the reality is hardly ever as bad as that, but I'd say having to deal with trivial API changes is a reasonable basis for a user to dislike a given project or try to avoid using it. It's up to the maintainers how friendly they want to be toward existing user code, and whether they pursue mitigating options like bundling migrations into less-common bigger updates.

Re: Deprecations via warnings don't work for Python libraries

#24
post #18

Fixing deprecations is unfortunately the lowest prio of any kind of work for majority of the projects. Part of the problem is probably lack of pressure to do so it if the timeline is unclear. What if this is actually never removed? Why going through the pain? IMO telling "we deprecate now and let's see when we remove it" is counterproductive. A better way: deprecate now and tell "in 12 (or 24?) months this WILL be re…

> Fixing deprecations is unfortunately the lowest prio of any kind of work for majority of the projects.

... and the right answer to that is to make it entirely their problem.

> Part of the problem is probably lack of pressure to do so it if the timeline is unclear. What if this is actually never removed?

In this case, the warnings said exactly what release would remove the API. Didn't help.

> Why going through the pain?

Because you're not a feckless irresponsible idiot? I don't think it's an accident that the projects they said didn't react were an overcomplicated and ill-designed management layer for an overcomplicated and ill-designed container system, a move-fast-and-break-things techbro company, and what looks to be a consolation project for the not-too-bright.

You probably get an extra measure of that if you're operating in the Python ecosystem, which is culturally all about half-assed, 80-percent-right-we-hope approaches.

The right answer is to remove it when you say you're going to remove it, and let them pick up the pieces.

It also helps if you design your API right to begin with, of course. But this is Python we're talking about again.

Re: Deprecations via warnings don't work for Python libraries

#25
post #2

Deprecations via warnings don't reliably work anywhere, in general. If you are a good developer, you'll have extensive unit test coverage and CI. You never see the unit test output (unless they fail) - so warnings go unnoticed. If you are a bad developer, you have no idea what you are doing and you ignore all warnings unless program crashes.

If you are a good developer, you consider warnings to be errors until proven otherwise.

Re: Deprecations via warnings don't work for Python libraries

#26
post #18

Fixing deprecations is unfortunately the lowest prio of any kind of work for majority of the projects. Part of the problem is probably lack of pressure to do so it if the timeline is unclear. What if this is actually never removed? Why going through the pain? IMO telling "we deprecate now and let's see when we remove it" is counterproductive. A better way: deprecate now and tell "in 12 (or 24?) months this WILL be re…

> After 12/24 months, cut a new semver-major release. People notice the semver-major through the dependency management tools at some point, an maybe they have a look at changelog.

The urllib3 package doesn't use SemVer.

Re: Deprecations via warnings don't work for Python libraries

#27
post #6

>We ended up adding the APIs back and creating a hurried release to fix the issue. So it was entirely possible to keep the software working with these. Why change/remove them in the first place? Is the benefit of of the new abstraction greater than the downside of requiring everyone using the software to re-write theirs?

I think this is a valid question for this specific case, but may not always be possible. That said, I think as a user I would probably prefer it if under the hood the old function called the new so they can deprecate the behavior without breaking the API. In that way you can still emit the deprecation warning while also only having one actual code path to maintain.

Re: Deprecations via warnings don't work for Python libraries

#28
post #13

Earlier quoted context omitted.

Why is it that CI tools don't make warnings visible? Why are they ignored by default in the first place? Seems like that should be a rather high priority.

It isn't that easy. If you have a new warning on upgrade you probably want to work on it "next week", but that means you need to ignore it for a bit. Or you might still want to support a really old version without the new API and so you can't fix it now.

> If you have a new warning on upgrade you probably want to work on it "next week", but that means you need to ignore it for a bit.

So you create a bug report or an issue or a story or whatever you happen to call it, and you make sure it gets tracked, and you schedule it with the rest of your work. That's not the same thing as "ignoring" it.

Re: Deprecations via warnings don't work for Python libraries

#29
The secret trick I've used on rare occasion, but when necessary, is the "ten second rule."

Users don't notice a deprecation warning. But they might notice adding a "time.sleep(10)" immediately at the top of the function. And that gives them one last grace period to change out their software before it breaks-breaks.

Re: Deprecations via warnings don't work for Python libraries

#30

I think they are misreading the situation. The devil is in the details. It seems `getHeaders` v. `headers` is non-security, non-performance related issue. Why people should spend time fixing these?

If you (either directly or from SerpApi) are supporting the urllib3 folks (through a Tidelift subscription), then yes, that is a valid point. Otherwise, I'd say that's a very brave comment you are making.

"Brave" in what sense? It's a legitimate question why an API is having a pattern deprecated and removed for what appears to be pattern reasons.
Post reply on HN