Skip to content

Code-level simplifications to tracing#226

Merged
goodboy merged 8 commits into
pytest-dev:masterfrom
bluetech:simplify-tracing
Aug 30, 2019
Merged

Code-level simplifications to tracing#226
goodboy merged 8 commits into
pytest-dev:masterfrom
bluetech:simplify-tracing

Conversation

@bluetech

Copy link
Copy Markdown
Member

A few minor changes relating to the tracing stuff. Please see the commits.

bluetech added 6 commits July 26, 2019 14:04
The way _TracedHookExecution is implemented, it takes the PluginManager
instance, which creates a cyclic dependency between the manager.py and
_tracing.py modules. It also mutates internal variables of
PluginManager. This makes the code harder to understand. Just inlining
it makes things mostly straightforward.

This commit also removes an assert which prevented a trace from being
added if there is already an active one. I don't see any reason why it
was done; seems like a legitimate thing to do and should work just fine.
This function is undocumented and unused internally.

pytest used to use it in a test case, but hasn't done so since 2010:
pytest-dev/pytest@b3628da#diff-5fd183e022c6cb9ca47f6c1ffc09eadeL274

A code search on GitHub only finds it inside copies of pluggy itself.
They are only directly used internally and not documented,

Makes it easier to see what is exposed.
It was only used as a kind of namespacing, but it makes things harder to
follow. Since TagTracerSub doesn't have any side-effects, avoid storing
it and make its use entirely localized.

pytest, devpi and tox don't use PluginManager.hook._trace.
If a KeyError is raised by the user-supplied processor function, it
should propagate.
The key is a "path" (tuple) of tags, not a single tag.
@codecov-io

codecov-io commented Jul 26, 2019

Copy link
Copy Markdown

Codecov Report

Merging #226 into master will increase coverage by 0.78%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #226      +/-   ##
==========================================
+ Coverage   93.08%   93.86%   +0.78%     
==========================================
  Files          14        9       -5     
  Lines        1677     1109     -568     
  Branches      117       19      -98     
==========================================
- Hits         1561     1041     -520     
+ Misses        101       66      -35     
+ Partials       15        2      -13
Impacted Files Coverage Δ
testing/test_tracer.py 100% <100%> (ø) ⬆️
src/pluggy/__init__.py
src/pluggy/callers.py

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a1c6c35...8900b4c. Read the comment docs.

@bluetech bluetech mentioned this pull request Jul 26, 2019
@bluetech bluetech changed the title Code-level simplicitations to tracing Code-level simplifications to tracing Jul 26, 2019

@nicoddemus nicoddemus left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall nice changes, sorry about the delay!

Comment thread src/pluggy/manager.py
Comment thread src/pluggy/_tracing.py
Comment thread src/pluggy/_tracing.py
Comment thread src/pluggy/_tracing.py

@bluetech bluetech left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the review @nicoddemus - left a reply.

Comment thread src/pluggy/_tracing.py
Comment thread src/pluggy/manager.py
@nicoddemus

Copy link
Copy Markdown
Member

Looks great, thanks again. @goodboy would you like to review as well?

Comment thread src/pluggy/_tracing.py
self._tag2proc = {}
self.writer = None
self._tags2proc = {}
self._writer = None

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as far as i can tell the "writer" is a "print" style function we ight be able to simplify

Comment thread src/pluggy/_tracing.py Outdated

@RonnyPfannschmidt RonnyPfannschmidt left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good, i wonder if setwriter could be deprecated in davour of naming _writertoprinter`

as far as i can tell, all writer is, is a optional printer

overall this is fine to merge as is, good work

@nicoddemus

Copy link
Copy Markdown
Member

@goodboy, absolutely no rush here, but would you like for us to wait here so you can review this, or are you OK with us merging this? 😁

@goodboy

goodboy commented Aug 28, 2019

Copy link
Copy Markdown
Contributor

@nicoddemus so sorry!
Been totally immersed in finishing up a music project.
I will take a look tonight!

@nicoddemus

Copy link
Copy Markdown
Member

No worries at all, take your time. 👍

@goodboy goodboy left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bluetech awesome work!

I made a couple minor notes but this looks great.
Thanks again!

Comment thread src/pluggy/_tracing.py Outdated
Comment thread src/pluggy/_tracing.py
Comment thread src/pluggy/_tracing.py
Comment thread src/pluggy/manager.py
@bluetech

Copy link
Copy Markdown
Member Author

Updated with @goodboy's suggestion.

@goodboy goodboy merged commit e40a877 into pytest-dev:master Aug 30, 2019
@goodboy

goodboy commented Aug 30, 2019

Copy link
Copy Markdown
Contributor

@bluetech thanks again for the help!

More eyes on this puppy is great to see!

@bluetech bluetech deleted the simplify-tracing branch June 28, 2020 08:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants