Live data from Hacker News

5% of 666 Python repos had comma typo bugs (inc V8, TensorFlow and PyTorch)

codereviewdoctor.medium.com

221–230 of 339 posts

Re: 5% of 666 Python repos had comma typo bugs (inc V8, TensorFlow and PyTorch)

#221
post #60

Earlier quoted context omitted.

Notice that, in the original quote, There should be one-- and preferably only one --obvious way to do it. the author used two different ways of hyphenating (three, if you count the whole PEP 20). PEP 20 is clearly not meant to be taken as law. Nor PEP 8. Nor PEP 257. People frequently mistake "one obvious way" with "one way". There are lots of ways to iterate through something, for example, but there is really one ob…

> the author used two different ways of hyphenating No, first, it doesn't use hyphenating at all, it uses hyphens as an ASCII approximation for typographical dashes used to set off a phrase (a distinct function from hyphenation), and, second, in that quote they used one way of doing it: “two dashes set closed on the side of the main sentence and set open on the side of set-off phrase”. It is an unusual way of doing i…

> “two dashes set closed on the side of the main sentence and set open on the side of set-off phrase”.

Eh, I don't think that's the interpretation the author was going for. The author wanted to show two different ways of approximating a dash, and he had limited options.

If he'd done this-- for example-- he would have been showing one way, not two.

If he'd done this --for example-- you would have called it "two dashes set open on the side of the main sentence and set closed on the side of set-off phrase".

If he'd done this-- for example -- it would have been too obvious (on the same line).

I suppose he could have done this-- for example--but I still think that would have been too obvious. You're not supposed to see it on a first read.

> And the third use (in the heading and later in the body) is seperating parts where neither is a mid-sentence appositive phrase, and uses open-on-both sides. So that's not a different way of doing the same thing, it's a different way of doing a semantically different thing.

It's a different use of a dash, but it's still a place where you'd typically use a dash.

-----

Edit: You know what, thinking about it again—perhaps both interpretations are valid. That almost adds to the effectiveness of the whole thing.

Re: 5% of 666 Python repos had comma typo bugs (inc V8, TensorFlow and PyTorch)

#222
post #133
post #115

Earlier quoted context omitted.

How is working with figure and axes objects the one that makes less sense? Is it really that crazy do set up a figure, axes on that figure, and plot on the axes, returning an artist object for each plotting command?

Yes, it is crazy. I guess this isn't really the place for it but ... From the official docs: The Figure is the final image that may contain 1 or more Axes. The Axes represent an individual plot (don't confuse this with the word "axis", which refers to the x/y axis of a plot). This is infuriatingly bad and I firmly believe that it makes sense only to people who already know how it works. There's an image, axes (this w…

>axes (this word alone is a crime),

why so? you prefer something like axiis?

Re: 5% of 666 Python repos had comma typo bugs (inc V8, TensorFlow and PyTorch)

#223
post #88

Earlier quoted context omitted.

Isn't that common for all/most languages that don't require explicit typing?

JavaScript (strict mode) doesn't have explicit typing, but it still requires variables to be declared.

Same for Perl.

Re: 5% of 666 Python repos had comma typo bugs (inc V8, TensorFlow and PyTorch)

#224

Earlier quoted context omitted.

> Complex is better than complicated What? Something being complex is artificial, we try to avoid it. Problems can be complicated, we try to simplify them, and more complicated the problem is, we tend to develop more complex solutions. So comparing them does not make sense? Or did I always know them wrong?

Complex: consisting of many different and connected parts. Complicated: consisting of many interconnecting parts or elements; intricate. Nothing specifically artificial about either one. Software that is well decomposed is Complex (made of many smaller connected parts). Software that is is poorly decomposed is Complicated (made of many smaller interconnected parts). Connected vs interconnected? Interconnected: connec…

Complicated: this mutha is hard all by itself

Complex: we took all of these simple steps, lumped them together, now we have this

Re: 5% of 666 Python repos had comma typo bugs (inc V8, TensorFlow and PyTorch)

#225
post #51

Earlier quoted context omitted.

The difference is: in C, it's pretty unlikely someone wants to add strings. I suppose it's even illegal in the later C versions.

It is positively not illegal in any standard verision of C since ANSI C 89. It's an essential feature used in all sorts of everyday code. C99 added printf conversion specifiers that are hidden behind macros, and idomatic usage of them relies on string catenation. uint32_t x = 0; printf("x = " PRIx32 "\n", x); where PRIx32 might expand to "%lx" (if uint32_t is the same as unsigned long in that compiler). All sorts of…

I know that. I meant that “abc” + “def” is most likely illegal (although “abc” + ‘d’ is not).

Re: 5% of 666 Python repos had comma typo bugs (inc V8, TensorFlow and PyTorch)

#226

For those looking to avoid this specific problem, there is a flake8 rule: https://pypi.org/project/flake8-no-implicit-concat . More broadly, the https://codereview.doctors makers are making the point that their tool caught an easy-to-miss issue that most wouldn't think to add a rule for. A bit of an open question to me how many of those there really are at the language level, but still seems like a neat project.

Also all but 1 of the issues they found relates to test code, it seems people are a little less careful compared to functional code. Also in terms of mistakes codereviewdoctor twice linked to the same issue in their blog https://github.com/tensorflow/tensorflow/issues/53636 and raised the PR to the wrong project https://github.com/tensorflow/tensorflow/pull/53637 (I guess Tensorflow vendors Keras, easy mistake)

https://github.com/tensorflow/tensorflow/tree/0d8705c82c64df...

    STOP!
    This folder contains the legacy Keras code which is stale and about to be deleted. The current Keras code lives in github/keras-team/keras.

    Please do not use the code from this folder.
Yeah, not the most obvious notice.

The fact they didn't find the same mistake(s) in keras-team/keras (I assume they scanned, it's one of the most popular Python repo) makes me believe these issues have been fixed/removed in up-to-date karas repo.

Re: 5% of 666 Python repos had comma typo bugs (inc V8, TensorFlow and PyTorch)

#227
post #47
post #24

Earlier quoted context omitted.

It's a class of error that would be caught by even the most basic testing. A better title for the article is that 5% of 666 Python repos have typos that demonstrate the code in them that is completely untested. It doesn't matter which language it is: untested code is untested code in any language.

unfortunately like 10% of the bugs were in the tests themselves. e.g., the sentry one https://codereviewdoctor.medium.com/5-of-666-python-repos-ha... the tests are only as good as the code they're written with, and as good as the code review process they were merged under.

I believe that, whenever possible, tests should be written in a different language that the one used for the code under test (even better, in a dedicated, mostly declarative, testing language).

It avoids replicating the same category of errors in both the test and the code under test, especially when some calculation or some sub-tests generation is made in the test.

Re: 5% of 666 Python repos had comma typo bugs (inc V8, TensorFlow and PyTorch)

#228
post #99

Earlier quoted context omitted.

The lack of a static type-system is IMO what makes these one-character mistakes very annoying. The compiler can't tell you something is wrong, so you're just left to figure out why things are broken, just to realize it was the smallest of typos.

I love how simple and forgiving Python is for small projects. The "trailing comma creates a tuple" situation comes out of, as far as I can tell, a desire to create maximally convenient syntax in the scenarios where tuples are intended. I think that's great for small code! I just wish that the core team would take that same zeal for a "pythonic" experience with small code and use it to develop more scaled-up systems f…

For a language that is so incredibly picky about it's whitespace rules, it's a little laissez faire on the string-concatentation/tuple syntax side. I say this as someone who loves python and uses it extensively.

Re: 5% of 666 Python repos had comma typo bugs (inc V8, TensorFlow and PyTorch)

#229
post #30

Earlier quoted context omitted.

I mean the zen being wrong is kind of a meme at this point. The whole “only one obvious way to do it” isn’t just false but the exact opposite is true. Python is one of the most flexible languages with many many ways to do the same thing; more than any other language I can think of.

Except exit. I knew Python wasn't for me in my first foray into it when I fired its REPL and then went to exit it with control-C or whatever and it literally printed out the right way to do it but then didn't do it. Python was more interested in having me do things a certain way even when it knew what I intended to do, just to be a twit .

The REPL prints the value of a variable that you type in. exit is a variable, and so the REPL prints its value. If you want to run it as a function, you can do that, and indeed its string value is a message telling you to do that.

    $ python3
    Python 3.9.2 (default, Feb 28 2021, 17:03:44)
    [GCC 10.2.1 20210110] on linux
    Type "help", "copyright", "credits" or "license" for more information.
    >>> exit
    Use exit() or Ctrl-D (i.e. EOF) to exit
    >>> exit.eof
    'Ctrl-D (i.e. EOF)'
    >>> exit.name
    'exit'
    >>> exit = 42
    >>> exit
    42
    >>> exit()
    Traceback (most recent call last):
      File "", line 1, in 
    TypeError: 'int' object is not callable
    >>>
I would have special-cased exit, though.

Re: 5% of 666 Python repos had comma typo bugs (inc V8, TensorFlow and PyTorch)

#230

Earlier quoted context omitted.

I dont think that's the same kind of thing. Your example is a tradeoff that anyone who uses a language that doesn't require explicit variable declaration faces, and it's pretty tough to argue such languages really shouldn't exist. Missing an operator resulting in explicit behavior is much more subtle and not even obvious behavior. For those who use python, it is worse.

> ...it's pretty tough to argue such languages really shouldn't exist. "Shouldn't exist" is too strong. Dynamic languages that let you create a new variable via assignment shouldn't be used to create non-trivial software. How about that? Scripting languages have a place. That place is 100% in creating quick-and-dirty scripts and tools. Or in doing some kind of one-off data transform (as is common in machine learning…

I've been building non-trivial software in dynamic languages for twenty years. They work great.

I'd take a project in a dynamic language with a decent test suite over a project without tests in a statically typed language any day of the week.

Post reply on HN