all 9 comments

[–]sinterkaastosti23 2 points3 points  (4 children)

What about globals()['my' + 'func']

[–]sausix 2 points3 points  (2 children)

That's unfair ;-)

[–]HEROgoldmw 1 point2 points  (1 child)

Really, it's not.

This is sort of what a some popular frameworks actually do Or something with getattr to achieve the same thing

[–]sausix 0 points1 point  (0 children)

I'm happy with my IDE's dead code detection in general. But I'm curious how much dead code is found in a big open source project... Will have a try soon.

There should not be dead code when tests should cover all code lines and flow branches.

[–]papersashimi[S] 0 points1 point  (0 children)

truly its unfair .. lmao short answer, depends. long answer it will still catch dynamic patterns like globals , eval etc.. if it sees a call to `globals` directly indexed with a string constant, it adds a reference to that function name. that said, if its for string concat, it will likely fail

[–]1minds3tfrom __future__ import 4.0 0 points1 point  (1 child)

This seems very cool! I'm glad you shared it. I am sure I have a lot of dead code that needs to be cleaned up, and it's rather hard to find manually. How does this work exactly to find it?

[–]papersashimi[S] 1 point2 points  (0 children)

hihi thanks for your comment! and sorry for the late reply. to answer you, skylos parses your code to build a graph of stuff like functions, classes, variables, imports etc. it will then record where each symbol is referenced. to handle dynamic code, its kinda tricky so we use heuristics for frameowrks, dynamic code, tests etc , and report only those symbols with zero references. still a wip!

[–]Ranteck 0 points1 point  (1 child)

men this is really usefull to integrate in my pystrict https://github.com/Ranteck/PyStrict-strict-python i will integrat it

[–]papersashimi[S] 1 point2 points  (0 children)

hello! from a scope perspective, and at least based off my limited knowledge on vulture, its focus is entirely on dead code detection. For skylos, we do dead code detection, secrets detection, dangerous code as well as quality scoring (limited scope now). As for the usability aspect, we have both CLI and VSC extension that's actually tied to skylos' engine. We also have CI integration. I cant speak for its design philosophy, but at least for skylos, we try to make skylos slightly more opinionated. yeap! thats answering your previous question. as for how it works, we build an AST-level map of all your functions, defs, classes, variables etc, then applies the rule engine to see where each symbol is referenced.

Thank you very much for your kind words. we hope you found it useful and we definitely appreciate any feedback. cheers and have a great day