Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add 'If' condition evaluation feature based on user input #590

Draft
wants to merge 15 commits into
base: master
Choose a base branch
from

Conversation

tristanlatr
Copy link
Contributor

@tristanlatr tristanlatr commented May 25, 2022

tristanlatr and others added 15 commits May 23, 2022 16:06
…re. The older visitor relied on generic_visit() to be recursive. Where the provided generic_visit() is not recursive anymore, and moreover not called automatically when visiting unknow nodes! So what I'm saying here is that since #576 have been merged, we're not visiting the statements inside the 'orelse' field of Try and If nodes, same goes for 'finalbody' and 'handlers'.

This commit fixes that issue. The rationale is now the following: All statements in the 'orelse' block of IF nodes and statements in the except handlers of TRY nodes that would override a name already defined in the main 'body' (or TRY 'orelse' or 'finalbody') are ignored.

Meaning that in the context of the code below, 'ssl' would resolve to 'twisted.internet.ssl':

try:
    from twisted.internet import ssl as _ssl
except ImportError:
    ssl = None
else:
    ssl = _ssl
Properly add support for that to override_guard() function instead.
…:twisted/pydoctor into visit-try-orelse-finalbody-and-if-orelse
@tristanlatr tristanlatr changed the title Choose type checking value for a module Add 'If' condition evaluation feature based on user input May 25, 2022
@tristanlatr tristanlatr marked this pull request as draft May 25, 2022 04:02
@codecov
Copy link

codecov bot commented May 25, 2022

Codecov Report

Merging #590 (2e18b5f) into master (21fa6ef) will increase coverage by 0.09%.
The diff coverage is 92.85%.

@@            Coverage Diff             @@
##           master     #590      +/-   ##
==========================================
+ Coverage   90.92%   91.01%   +0.09%     
==========================================
  Files          45       45              
  Lines        7699     7777      +78     
  Branches     1668     1693      +25     
==========================================
+ Hits         7000     7078      +78     
  Misses        435      435              
  Partials      264      264              
Impacted Files Coverage Δ
pydoctor/astutils.py 79.31% <71.42%> (-0.94%) ⬇️
pydoctor/astbuilder.py 94.98% <94.36%> (+0.05%) ⬆️
pydoctor/extensions/deprecate.py 100.00% <100.00%> (ø)
pydoctor/model.py 93.23% <100.00%> (+0.01%) ⬆️
pydoctor/extensions/zopeinterface.py 93.11% <0.00%> (+0.45%) ⬆️
pydoctor/visitor.py 93.89% <0.00%> (+3.05%) ⬆️

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 21fa6ef...2e18b5f. Read the comment docs.

@tristanlatr
Copy link
Contributor Author

Should this feature be a proper option or it should stay a system class variable to override ? It's likely that other projects will need the same kind of adjustments as Klein, so maybe it should.

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.

Handling of "if TYPE_CHECKING:" blocks
1 participant