pamelafox, to random
@pamelafox@fosstodon.org avatar

I just did a lecture on debugging in Python, and in one example, I override the sum() built-in. Students were shocked that Python let me override a built-in without any warning at all. Are there linters that check for that? Or modes to warn about it?

blakeNaccarato,
@blakeNaccarato@fosstodon.org avatar

@pamelafox

Installing flake8 and flake8-builtins extension would solve the immediate issue, provided students are using an IDE that supports flake8. Maintaining a set of student virtual environments with a bunch of flake-8 plugins may get unwieldy.

I link to Ruff's doc since ruff bundles hundreds of these rules, and can be configured by TOML to selectively enable rules to reduce overwhelm and target outcomes. Higher startup cost, but easier to juggle rules.

https://docs.astral.sh/ruff/rules/#flake8-builtins-a

treyhunner, to python
@treyhunner@mastodon.social avatar

Ever seen "lambda" in #Python?

That's a function.

But wait... aren't functions made with "def" statements? How are lambda functions different and why are they used?

That's the topic of this week's Python Morsels article.

https://pym.dev/lambda-expressions/

cazabon,

@treyhunner

It still pisses me off that #flake8 complains if you ever bind a #lambda to a name. "Use a #function instead!" it whines.

Every time, I want to channel #Kimi #Raikonnen: "Leave me alone, I know what I'm doing!"

#lint #PITA #opinionated

benfulton, to random

Using cyclomatic complexity in code reviews. That would be an interesting experiment - I had no idea that CC was measurable in C++ code! Metrix++ is the relevant tool.

pawamoy,
@pawamoy@fosstodon.org avatar

@benfulton @leahawasser I think most Python tools that measure cyclomatic complexity are based on or use McCabe, from @nedbat (https://pypi.org/project/mccabe/). has it built-in, has plugins (McCabe is one), probably has it built-in too.

adamchainz, to python
@adamchainz@fosstodon.org avatar

✍️ New post introducing my new plugin that checks your usage of ’s logging module.

https://adamj.eu/tech/2023/09/07/introducing-flake8-logging/

elijahwilson, to random
@elijahwilson@fosstodon.org avatar

Configuring a max length for comments in that's different than the normal max length would be fantastic. It's ugly to write a comment and on the same line need to use # noqa: E501...

  • All
  • Subscribed
  • Moderated
  • Favorites
  • megavids
  • khanakhh
  • mdbf
  • ethstaker
  • magazineikmin
  • GTA5RPClips
  • rosin
  • thenastyranch
  • Youngstown
  • InstantRegret
  • slotface
  • osvaldo12
  • kavyap
  • DreamBathrooms
  • JUstTest
  • Durango
  • everett
  • cisconetworking
  • normalnudes
  • tester
  • ngwrru68w68
  • cubers
  • modclub
  • tacticalgear
  • provamag3
  • Leos
  • anitta
  • lostlight
  • All magazines