3 ms·
> is that a class without a constructor might not really be a class at all. Yes, but there are several cases where this doesn't matter. Exceptions for example.
by raverbashing 10y ago
> is that a class without a constructor might not really be a class at all.
Yes, but there are several cases where this doesn't matter. Exceptions for example.
> Number and size of methods are both code smells
Yes, but Pylint's default values comes from where? It's pretty easy to trigger them without being a God object
20 methods is fine, 50 lines is what fits in my terminal, and a lot of functions don't fit that (especially with blank lines, splitting lines bigger than 80 chars, etc
- deleted 10y ago[deleted]
- frobozz 10y ago> Exceptions for example. Exceptions are not an example. They should inherit from BaseException (PEP-352). BaseException has __init__, therefore any Exception has __init__ by inheritance. > 50 lines is what fits in my terminal, 50 statements, not 50 lines. Blank lines aren't statements, splitting a long line doesn't turn it into two statements. It's pretty rare to have a 50 statement method that doesn't violate Curly's Law. Personally, I'd make it much smaller. Depending on how much commentary and whitespace you put in, you could have 150 or more lines in a 50 statement function. > Yes, but Pylint's default values comes from where? It doesn't matter, pylint isn't an academic paper that requires every assertion to be backed up by experimental data and citations from peer-reviewed journals. It's a handy and easily configurable tool. I would guess that the numbers came from a couple of pylint developers having a conversation like "50 statements is pretty big for a function isn't it? Yes, let's make that the default limit." Were it hard-coded as a magic number deep in the pylint code, then perhaps they might need a bit more experimental validation behind those numbers.