laike9m / Cyberbrain

Python debugging, redefined.
http://bit.ly/cyberbrain-features
MIT License
2.51k stars 159 forks source link

124 more accurate function definition lineno #130

Closed Turtle24 closed 3 years ago

Turtle24 commented 3 years ago

124 The traceback module seems to achieve what you want. I tried the undecorated idea but I couldn't figure out how to reverse or go back and use the logic to count the decorators or get the functions line no. Anyway I hope this does the trick.

laike9m commented 3 years ago

Thanks for the PR! Please fix the tests. I'll take a look tonight.

Turtle24 commented 3 years ago

Thanks for the PR! Please fix the tests. I'll take a look tonight.

When I run the tests individually they pass but when I run the suite some are throwing Errors. Is there a state carried over or am I being silly? I've changed some of the mocks because of the defined lineno being the function now but I'm not sure why individually run tests pass and then the suite run causes Errors.

sourcery-ai[bot] commented 3 years ago

Sourcery Code Quality Report

❌  Merging this PR will decrease code quality in the affected files by 0.17%.

Quality metrics Before After Change
Complexity 4.88 ⭐ 4.83 ⭐ -0.05 👍
Method Length 55.12 ⭐ 55.61 ⭐ 0.49 👎
Working memory 6.57 🙂 6.61 🙂 0.04 👎
Quality 73.84% 🙂 73.67% 🙂 -0.17% 👎
Other metrics Before After Change
Lines 592 609 17
Changed files Quality Before Quality After Quality Change
cyberbrain/tracer.py 76.74% ⭐ 76.12% ⭐ -0.62% 👎
test/test_api_state.py 86.30% ⭐ 86.30% ⭐ 0.00%
test/test_generator.py 79.52% ⭐ 79.52% ⭐ 0.00%
test/test_recursion.py 81.50% ⭐ 81.50% ⭐ 0.00%
test/test_while_loop.py 53.24% 🙂 53.24% 🙂 0.00%

Here are some functions in these files that still need a tune-up:

File Function Complexity Length Working Memory Quality Recommendation
test/test_while_loop.py test_while_loop 13 🙂 397 ⛔ 7 🙂 45.33% 😞 Try splitting into smaller methods
test/test_generator.py test_generator_function 3 ⭐ 154 😞 8 🙂 63.78% 🙂 Try splitting into smaller methods
cyberbrain/tracer.py Tracer.global_tracer 2 ⭐ 38 ⭐ 11 😞 74.54% 🙂 Extract out complex expressions

Legend and Explanation

The emojis denote the absolute quality of the code:

The 👍 and 👎 indicate whether the quality has improved or gotten worse with this pull request.


Please see our documentation here for details on how these metrics are calculated.

We are actively working on this report - lots more documentation and extra metrics to come!

Help us improve this quality report!

Turtle24 commented 3 years ago

Can we add some comments on what makes 3.7 different?

Yeah I've been looking into it, I was getting different results between my local tests and the CI/CD so I was just comparing the errors and failures with that push. I'll try sort it out this weekend.

laike9m commented 3 years ago

Great, thanks for the hard work. If you need any help, let me know. You can find me on Discord.

Turtle24 commented 3 years ago

Great, thanks for the hard work. If you need any help, let me know. You can find me on Discord.

It's a pleasure, it's been a nice learning experience. I joined the Discord. I'm in France so I think the timezone difference is a bit meh. So for Python 3.7 the problem is that the stack summary is the same besides the fact that it identifies the module origination on the trace decorator line and not the function definition. Adding one to the lineno gives the same outcome for python 3.7 even with multiple decorators.

laike9m commented 3 years ago

LGTM, Thanks!