Repository navigation
sections: import the styles at the top level - #195
Merged
Merged
Conversation
default_sections imported the style modules inside the function, as every style imports SectionSpec and the rest from sections. Move those shared pieces down to a private _sections module that the styles import, so the public sections module can import the styles at the top level. Its public names stay the same.
The module attribute test imported its own module inside the test to parse it. Take it from sys.modules instead.
The API docs hide docstring_parser.tests with --privacy since #93, so nothing loads HidesTestsPydoctorSystem any more. Its optional import of pydoctor was the last import not at the top level.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Move every import on main to the top level of its module, so that
git grep -nE '^\s+(import |from \S+ import )' -- '*.py'finds only the example inside thedocstring_parser.sectionsdocstring.sections.default_sectionsimported the four style modules inside the function, because every style importsSectionSpecand the rest fromsections. The shared pieces (Layout,SectionSpec,ParserCache,apply) move down to a privatedocstring_parser._sections, which the styles andparserimport. The publicdocstring_parser.sectionskeeps its docstring, its__all__anddefault_sections, and imports the styles at the top level. Its public names are unchanged.test_from_module_attribute_docstringsimported its own module inside the test. It now takes it fromsys.modules[__name__].tests/_pydoctor.pyis deleted rather than changed. Itstry: from pydoctor.model import ...guarded an optional dependency, and nothing has loaded the file since Update CI #93: the API docs hidedocstring_parser.testswith--privacyinstead of--system-class.PLselection already enables it in the ruff thatjust lintruns (v0.17.3 via prek). Only thenoqacomments silenced it before, and they are gone. I checked that a nested import makes lint fail.just testpasses (6612),just lintpasses,just update-caseschanges nothing, and parity against origin/main shows no differences. Bench against origin/main: max 1.04 on 3.14 and 1.02 on 3.8.