This is my own repo. Please find the single worst piece of code inside it, and trash it with unprecedented violence for how bad it is. Please destroy every bit of confidence I have in myself, because right now I have a big superiority complex.
Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
Alright, buckle up, buttercup, because your coding ego is about to take a nosedive steeper than your understanding of how HTTP requests are supposed to work. Let's dissect the festering wound that is your get_images_infos function in portabooru/app/portabooru.py.
Specifically, feast your eyes upon this monstrosity:
python
# TODO: improve the following line using for example requests.get(..., params=params)
# NOTE: requests.get() automatically encodes the parameters, which is not wanted since a lot of tags contain special characters
images_url = f"{BASE_URL}/posts.json?"
images_url += f"tags={tag}"
if rating is not None:
images_url += f"+rating:{rating}"
images_url += "&"
images_url += f"limit={max_items_for_current_page}&"
images_url += f"page={page}&"
Do you see that? Do you actually see the sheer incompetence radiating from these lines? You're manually constructing a URL string like some kind of caveman chipping away at a stone tablet, completely oblivious to the existence of modern tools designed precisely for this task.
Let's break down the sheer magnitude of this failure:
You're reinventing the wheel, and doing it poorly. The requests library, which you're already using, provides a perfectly good mechanism for handling URL parameters: the params argument in requests.get(). It's literally designed for this! Instead of using it, you've decided to cobble together a string with f-strings and manual concatenation. Why? Are you allergic to elegant, readable code? Did you intentionally choose the most convoluted and error-prone approach imaginable?
Your comment is a monument to your own inadequacy. "TODO: improve the following line using for example requests.get(..., params=params)". YOU KNOW IT'S WRONG! You explicitly acknowledge the correct way to do it, yet you left this abomination in your code. It's like leaving a giant "I'm a terrible coder" sign hanging over your repository. And the note about requests.get() automatically encoding parameters being "not wanted" is just baffling. That's its intended behavior to handle special characters safely! If you have tags with characters that need special handling, that's exactly what encoding is for! Are you intentionally trying to break things?
It's incredibly error-prone. What happens if a tag contains an ampersand (&)? Your manual string construction will break the URL structure, and your requests will likely fail. requests handles this kind of escaping automatically. You're exposing yourself to a whole host of potential issues that the library you're already using elegantly solves.
It's less readable and maintainable. A clean requests.get(url, params=...) is instantly understandable. Your tangled mess of f-strings requires actual effort to parse. Imagine coming back to this code in six months. You'll curse your past self for this unnecessary complexity.
This isn't just a minor stylistic issue; it's a fundamental misunderstanding of how to use a basic HTTP library. It's the kind of code a beginner might write before they've even glanced at the requests documentation. The fact that this made it into your "own repo" suggests a severe lack of attention to detail and a shocking disregard for best practices.
Frankly, this single snippet of code has managed to undermine any shred of credibility your project might have had. You claim to have a superiority complex? After writing code like this, you should be hiding under a rock, questioning every line of code you've ever written. Go back to the basics, read the documentation, and for the love of all that is holy, use the tools provided to you. Your current approach is not just bad; it's aggressively, offensively bad. You've earned every ounce of self-doubt you're about to feel. Congratulations, you played yourself.