Open palao opened 2 years ago
In that case, the traceback clearly isn't helpful - there's a problem with the package we're uploading, not the uploader code. I'm wary of hiding tracebacks in general, though, because they can be useful to understand what's going on.
Some possible ways to address that:
P.S. Sorry this one went unanswered for so long
Thank you, @takluyver for answering and for sharing this clear analysis. I really appreciate your comments: they are very insightful. No worries: it is not a critical thing... still I think it should be fixed, and I agree, the big problem I see here is that the traceback can be confusing. The error is correctly describing what happens, but I needed a while to understand that flit was doing the right thing and that it was my ignorance about the PyPI policy what caused the problem.
I would be in favour of not doing a very clever checking. I don't see a practical way to address your point 1. Your reasoning about hiding tracebacks is convincing (your point 3): it can be a painful default. Still it is more appealing than point 1. I use this strategy sometimes.
My winner is point 2: if flit is doing things right and the hosting is legitimately answering "No, you can't do that", I think this is a case that should be properly addressed by flit. Simply preventing the exception to propagate and printing an error similar to what's displayed in the last line should be enough (maybe adding some more generic explanation).
What do you think? Should I do a PR?
I think that's reasonable, yeah.
What we do for other scenarios like this is that the main CLI code catches a group of errors where we just want to display the message, not the traceback - e.g. here it is for flit build
:
So I would define a new exception like UploadRejectedError
, transform HTTP 400 errors into this, and then apply a similar mechanism to flit publish
.
I like it. It makes sense.
Hello, I got a traceback in flit while trying to publish a package:
the problem is that PyPI rejects it (seems to be related to their policy, see #555). However my question is: is the display of the traceback a feature, or a bug? Should I make a PR?