-
Notifications
You must be signed in to change notification settings - Fork 49
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
Handling of attrs/dataclass/pydantic/namedtuple constructors #656
base: master
Are you sure you want to change the base?
Conversation
…tected constructor Function.
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #656 +/- ##
==========================================
- Coverage 92.69% 92.52% -0.17%
==========================================
Files 47 48 +1
Lines 8285 8580 +295
Branches 1826 1896 +70
==========================================
+ Hits 7680 7939 +259
- Misses 347 370 +23
- Partials 258 271 +13 ☔ View full report in Codecov by Sentry. |
…ydoctor into 718-dataclass-like-abstraction
Include the factory call as default value when possible.
This comment has been minimized.
This comment has been minimized.
…octor into 305-handling-of-constructors
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
…octor into 305-handling-of-constructors
Diff from pydoctor_primer, showing the effect of this PR on open source code: bottle (https://github.com/bottlepy/bottle): typechecking got 15.23x faster (13.8s -> 0.9s)
(Performance measurements are based on a single noisy sample)
+ Traceback (most recent call last):
+ File "/new_pydoctor/venv/bin/pydoctor", line 8, in <module>
+ sys.exit(main())
+ ^^^^^^
+ File "/new_pydoctor/venv/lib/python3.11/site-packages/pydoctor/driver.py", line 166, in main
+ system = get_system(options)
+ ^^^^^^^^^^^^^^^^^^^
+ File "/new_pydoctor/venv/lib/python3.11/site-packages/pydoctor/driver.py", line 33, in get_system
+ system = options.systemclass(options)
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ File "/new_pydoctor/venv/lib/python3.11/site-packages/pydoctor/model.py", line 975, in __init__
+ extensions.load_extension_module(self, ext)
+ File "/new_pydoctor/venv/lib/python3.11/site-packages/pydoctor/extensions/__init__.py", line 209, in load_extension_module
+ setup_pydoctor_extension(ExtRegistrar(system))
+ File "/new_pydoctor/venv/lib/python3.11/site-packages/pydoctor/extensions/attrs.py", line 608, in setup_pydoctor_extension
+ r.register_mixin(AttrsLikeClass)
+ File "/new_pydoctor/venv/lib/python3.11/site-packages/pydoctor/extensions/__init__.py", line 181, in register_mixin
+ self.system._factory.add_mixins(**_get_mixins(*mixin))
+ ^^^^^^^^^^^^^^^^^^^
+ File "/new_pydoctor/venv/lib/python3.11/site-packages/pydoctor/extensions/__init__.py", line 113, in _get_mixins
+ assert False, f"Invalid mixin {mixin.__name__!r}. Mixins must subclass one of the base class."
+ AssertionError: Invalid mixin 'AttrsLikeClass'. Mixins must subclass one of the base class.
- /projects/bottle/bottle.py:3012: bad docstring: Definition list ends without a blank line; unexpected unindent.
- /projects/bottle/bottle.py:3591: ambiguous ref to name, could be bottle.Route.name, bottle.HeaderProperty.name, bottle.JSONPlugin.name, bottle.TemplatePlugin.name, bottle._ImportRedirect.name, bottle.FileUpload.name, bottle.BaseTemplate.name
- /projects/bottle/bottle.py:3591: Cannot find link target for "name"
- /projects/bottle/bottle.py:3591: Cannot find link target for "pack.mod" (you can link to external docs with --intersphinx)
- /projects/bottle/bottle.py:3592: Cannot find link target for "pack.mod.func" (you can link to external docs with --intersphinx)
- /projects/bottle/bottle.py:3128: Parameter "script_name" was already documented
- /projects/bottle/bottle.py:3641: Cannot find link target for "wsgiref"
- /projects/bottle/bottle.py:3649: Documented parameter "options" does not exist, variable keywords should be documented with the "keyword" field
- /projects/bottle/bottle.py:2843: Cannot find link target for "Save as..." (you can link to external docs with --intersphinx)
- /projects/bottle/bottle.py:295: Cannot find link target for "/contact"
- /projects/bottle/bottle.py:296: Cannot find link target for "page"
- /projects/bottle/bottle.py:297: Cannot find link target for "routing"
- /projects/bottle/bottle.py:804: Cannot find link target for "Plugin"
- /projects/bottle/bottle.py:778: Cannot find link target for "/prefix"
- /projects/bottle/bottle.py:779: Cannot find link target for "/prefix/"
- /projects/bottle/bottle.py:767: Cannot find link target for "mount-point"
- /projects/bottle/bottle.py:900: Cannot find link target for "Plugin.apply" (you can link to external docs with --intersphinx)
- /projects/bottle/bottle.py:889: Cannot find link target for "GET"
- /projects/bottle/bottle.py:889: Cannot find link target for "PUT"
- /projects/bottle/bottle.py:889: Cannot find link target for "GET"
- /projects/bottle/bottle.py:1206: Cannot find link target for "Signed Cookie"
- /projects/bottle/bottle.py:1207: Cannot find link target for "secret"
- /projects/bottle/bottle.py:1362: Cannot find link target for "io.BytesIO" (you can link to external docs with --intersphinx)
- /projects/bottle/bottle.py:1364: Cannot find link target for "seek(0)"
- /projects/bottle/bottle.py:1261: Cannot find link target for "multipart/form-data"
- /projects/bottle/bottle.py:1237: Cannot find link target for "url-encoded"
- /projects/bottle/bottle.py:1237: Cannot find link target for "multipart/form-data"
- /projects/bottle/bottle.py:1483: Cannot find link target for "X-Requested-With"
- /projects/bottle/bottle.py:1381: Cannot find link target for "cgi.FieldStorage" (you can link to external docs with --intersphinx)
- /projects/bottle/bottle.py:1421: Cannot find link target for "urlparse.SplitResult" (you can link to external docs with --intersphinx)
- /projects/bottle/bottle.py:1882: Cannot find link target for "domain"
- /projects/bottle/bottle.py:1882: ambiguous ref to path, could be bottle.BaseRequest.path, bottle.ResourceManager.path
- /projects/bottle/bottle.py:1882: Cannot find link target for "path"
- /projects/bottle/bottle.py:1801: Cannot find link target for "secret"
- /projects/bottle/bottle.py:1802: Cannot find link target for "Signed Cookie"
- /projects/bottle/bottle.py:1809: Cannot find link target for "cookie.Morsel" (you can link to external docs with --intersphinx)
- /projects/bottle/bottle.py:1822: Cannot find link target for "maxage"
- /projects/bottle/bottle.py:1811: Documented parameter "maxage" does not exist, variable keywords should be documented with the "keyword" field
- /projects/bottle/bottle.py:1812: Documented parameter "expires" does not exist, variable keywords should be documented with the "keyword" field
- /projects/bottle/bottle.py:1813: Documented parameter "domain" does not exist, variable keywords should be documented with the "keyword" field
- /projects/bottle/bottle.py:1815: Documented parameter "path" does not exist, variable keywords should be documented with the "keyword" field
- /projects/bottle/bottle.py:1816: Documented parameter "secure" does not exist, variable keywords should be documented with the "keyword" field
- /projects/bottle/bottle.py:1817: Documented parameter "httponly" does not exist, variable keywords should be documented with the "keyword" field
- /projects/bottle/bottle.py:1820: Cannot find link target for "lax"
- /projects/bottle/bottle.py:1820: Cannot find link target for "strict"
- /projects/bottle/bottle.py:1820: Cannot find link target for "none"
- /projects/bottle/bottle.py:1819: Documented parameter "samesite" does not exist, variable keywords should be documented with the "keyword" field
- /projects/bottle/bottle.py:2021: Cannot find link target for "template_engine"
- /projects/bottle/bottle.py:2404: Cannot find link target for "python:configparser.ConfigParser" (you can link to external docs with --intersphinx)
- /projects/bottle/bottle.py:2670: Cannot find link target for "/"
- /projects/bottle/bottle.py:2707: Cannot find link target for "None"
- /projects/bottle/bottle.py:3476: Cannot find link target for "backlog"
- /projects/bottle/bottle.py:3479: Cannot find link target for "family"
- these 1 objects' docstrings contain syntax errors:
- bottle._parse_http_header
attrs (https://github.com/python-attrs/attrs)
+ Traceback (most recent call last):
+ File "/new_pydoctor/venv/bin/pydoctor", line 8, in <module>
+ sys.exit(main())
+ ^^^^^^
+ File "/new_pydoctor/venv/lib/python3.11/site-packages/pydoctor/driver.py", line 166, in main
+ system = get_system(options)
+ ^^^^^^^^^^^^^^^^^^^
+ File "/new_pydoctor/venv/lib/python3.11/site-packages/pydoctor/driver.py", line 33, in get_system
+ system = options.systemclass(options)
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ File "/new_pydoctor/venv/lib/python3.11/site-packages/pydoctor/model.py", line 975, in __init__
+ extensions.load_extension_module(self, ext)
+ File "/new_pydoctor/venv/lib/python3.11/site-packages/pydoctor/extensions/__init__.py", line 209, in load_extension_module
+ setup_pydoctor_extension(ExtRegistrar(system))
+ File "/new_pydoctor/venv/lib/python3.11/site-packages/pydoctor/extensions/attrs.py", line 608, in setup_pydoctor_extension
+ r.register_mixin(AttrsLikeClass)
+ File "/new_pydoctor/venv/lib/python3.11/site-packages/pydoctor/extensions/__init__.py", line 181, in register_mixin
+ self.system._factory.add_mixins(**_get_mixins(*mixin))
+ ^^^^^^^^^^^^^^^^^^^
+ File "/new_pydoctor/venv/lib/python3.11/site-packages/pydoctor/extensions/__init__.py", line 113, in _get_mixins
+ assert False, f"Invalid mixin {mixin.__name__!r}. Mixins must subclass one of the base class."
+ AssertionError: Invalid mixin 'AttrsLikeClass'. Mixins must subclass one of the base class.
- /projects/attrs/src/attr/_make.py:2573: bad docstring: No role entry for "ref" in module "docutils.parsers.rst.languages.en".
- Trying "ref" as canonical role name.
- /projects/attrs/src/attr/_make.py:2573: bad docstring: Unknown interpreted text role "ref".
- /projects/attrs/src/attr/_make.py:2584: bad docstring: No role entry for "ref" in module "docutils.parsers.rst.languages.en".
- Trying "ref" as canonical role name.
- /projects/attrs/src/attr/_make.py:2584: bad docstring: Unknown interpreted text role "ref".
- /projects/attrs/src/attr/_make.py:497: bad docstring: Inline interpreted text or phrase reference start-string without end-string.
- /projects/attrs/src/attr/_make.py:497: bad docstring: Inline interpreted text or phrase reference start-string without end-string.
- /projects/attrs/src/attr/filters.py:13: bad docstring: Inline interpreted text or phrase reference start-string without end-string.
- /projects/attrs/src/attr/_make.py:162: bad docstring: No role entry for "ref" in module "docutils.parsers.rst.languages.en".
- Trying "ref" as canonical role name.
- /projects/attrs/src/attr/_make.py:162: bad docstring: Unknown interpreted text role "ref".
- /projects/attrs/src/attr/_make.py:212: bad docstring: No role entry for "ref" in module "docutils.parsers.rst.languages.en".
- Trying "ref" as canonical role name.
- /projects/attrs/src/attr/_make.py:212: bad docstring: Unknown interpreted text role "ref".
- /projects/attrs/src/attr/_make.py:1334: bad docstring: No role entry for "term" in module "docutils.parsers.rst.languages.en".
- Trying "term" as canonical role name.
- /projects/attrs/src/attr/_make.py:1334: bad docstring: Unknown interpreted text role "term".
- /projects/attrs/src/attr/_make.py:1437: bad docstring: No role entry for "term" in module "docutils.parsers.rst.languages.en".
- Trying "term" as canonical role name.
- /projects/attrs/src/attr/_make.py:1437: bad docstring: Unknown interpreted text role "term".
- /projects/attrs/src/attr/_make.py:1437: bad docstring: No role entry for "term" in module "docutils.parsers.rst.languages.en".
- Trying "term" as canonical role name.
- /projects/attrs/src/attr/_make.py:1437: bad docstring: Unknown interpreted text role "term".
- /projects/attrs/src/attr/_make.py:1484: bad docstring: No role entry for "ref" in module "docutils.parsers.rst.languages.en".
- Trying "ref" as canonical role name.
- /projects/attrs/src/attr/_make.py:1484: bad docstring: Unknown interpreted text role "ref".
- /projects/attrs/src/attr/_next_gen.py:62: bad docstring: No role entry for "term" in module "docutils.parsers.rst.languages.en".
- Trying "term" as canonical role name.
- /projects/attrs/src/attr/_next_gen.py:62: bad docstring: Unknown interpreted text role "term".
- /projects/attrs/src/attr/_cmp.py:45: Cannot find link target for "comparison"
- /projects/attrs/src/attr/_cmp.py:29: Documented parameter "typing.Callable | None eq" does not exist
- /projects/attrs/src/attr/_cmp.py:31: Documented parameter "typing.Callable | None lt" does not exist
- /projects/attrs/src/attr/_cmp.py:33: Documented parameter "typing.Callable | None le" does not exist
- /projects/attrs/src/attr/_cmp.py:35: Documented parameter "typing.Callable | None gt" does not exist
- /projects/attrs/src/attr/_cmp.py:37: Documented parameter "typing.Callable | None ge" does not exist
- /projects/attrs/src/attr/_cmp.py:40: Cannot find link target for "True"
- /projects/attrs/src/attr/_cmp.py:41: Cannot find link target for "NotImplemented"
- /projects/attrs/src/attr/_cmp.py:40: Documented parameter "bool require_same_type" does not exist
- /projects/attrs/src/attr/_cmp.py:43: Documented parameter "str | None class_name" does not exist
- /projects/attrs/src/attr/_funcs.py:25: Documented parameter "bool recurse" does not exist
- /projects/attrs/src/attr/_funcs.py:27: Cannot find link target for "True"
- /projects/attrs/src/attr/_funcs.py:28: Cannot find link target for "False"
- /projects/attrs/src/attr/_funcs.py:26: Documented parameter "~typing.Callable filter" does not exist
- /projects/attrs/src/attr/_funcs.py:30: Documented parameter "~typing.Callable dict_factory" does not exist
- /projects/attrs/src/attr/_funcs.py:33: Cannot find link target for "list"
- /projects/attrs/src/attr/_funcs.py:34: Cannot find link target for "tuple"
- /projects/attrs/src/attr/_funcs.py:34: Cannot find link target for "set"
- /projects/attrs/src/attr/_funcs.py:35: Cannot find link target for "True"
- /projects/attrs/src/attr/_funcs.py:33: Documented parameter "bool retain_collection_types" does not exist
- /projects/attrs/src/attr/_funcs.py:36: Documented parameter "typing.Callable | None value_serializer" does not exist
- /projects/attrs/src/attr/_funcs.py:209: Documented parameter "bool recurse" does not exist
- /projects/attrs/src/attr/_funcs.py:211: Cannot find link target for "True"
- /projects/attrs/src/attr/_funcs.py:212: Cannot find link target for "False"
- /projects/attrs/src/attr/_funcs.py:210: Documented parameter "~typing.Callable filter" does not exist
- /projects/attrs/src/attr/_funcs.py:214: Documented parameter "~typing.Callable tuple_factory" does not exist
- /projects/attrs/src/attr/_funcs.py:216: Cannot find link target for "list"
- /projects/attrs/src/attr/_funcs.py:216: Cannot find link target for "dict"
- /projects/attrs/src/attr/_funcs.py:217: Cannot find link target for "tuple"
- /projects/attrs/src/attr/_funcs.py:216: Cannot find link target for "dict"
- /projects/attrs/src/attr/_funcs.py:217: Cannot find link target for "set"
- /projects/attrs/src/attr/_funcs.py:218: Cannot find link target for "True"
- /projects/attrs/src/attr/_funcs.py:216: Documented parameter "bool retain_collection_types" does not exist
- /projects/attrs/src/attr/_funcs.py:371: Documented parameter "inst" does not exist, variable keywords should be documented with the "keyword" field
- /projects/attrs/src/attr/_funcs.py:308: Documented parameter "type cls" does not exist
- /projects/attrs/src/attr/_funcs.py:426: Cannot find link target for "typing.get_type_hints" (you can link to external docs with --intersphinx)
- /projects/attrs/src/attr/_funcs.py:428: Documented parameter "type cls" does not exist
- /projects/attrs/src/attr/_funcs.py:429: Documented parameter "dict | None globalns" does not exist
- /projects/attrs/src/attr/_funcs.py:430: Documented parameter "dict | None localns" does not exist
- /projects/attrs/src/attr/_funcs.py:431: Documented parameter "list | None attribs" does not exist
- /projects/attrs/src/attr/_funcs.py:434: Documented parameter "bool include_extras" does not exist
- /projects/attrs/src/attr/_make.py:239: Cannot find link target for "None"
- /projects/attrs/src/attr/_make.py:135: Cannot find link target for "TypeError"
- /projects/attrs/src/attr/_make.py:140: Cannot find link target for "defaults"
- /projects/attrs/src/attr/_make.py:142: Documented parameter "~typing.Callable factory" does not exist
- /projects/attrs/src/attr/_make.py:148: Cannot find link target for "~attrs.Attribute" (you can link to external docs with --intersphinx)
- /projects/attrs/src/attr/_make.py:153: Cannot find link target for "list"
- /projects/attrs/src/attr/_make.py:145: Documented parameter "~typing.Callable | list[~typing.Callable] validator" does not exist
- /projects/attrs/src/attr/_make.py:164: Cannot find link target for "True"
- /projects/attrs/src/attr/_make.py:165: Cannot find link target for "False"
- /projects/attrs/src/attr/_make.py:163: Documented parameter "bool | ~typing.Callable repr" does not exist
- /projects/attrs/src/attr/_make.py:171: Cannot find link target for "True"
- /projects/attrs/src/attr/_make.py:177: Cannot find link target for "comparison"
- /projects/attrs/src/attr/_make.py:171: Documented parameter "bool | ~typing.Callable eq" does not exist
- /projects/attrs/src/attr/_make.py:179: Cannot find link target for "True"
- /projects/attrs/src/attr/_make.py:185: Cannot find link target for "comparison"
- /projects/attrs/src/attr/_make.py:179: Documented parameter "bool | ~typing.Callable order" does not exist
- /projects/attrs/src/attr/_make.py:190: Cannot find link target for "comparison"
- /projects/attrs/src/attr/_make.py:191: Cannot find link target for "bool"
- /projects/attrs/src/attr/_make.py:191: Cannot find link target for "callable"
- /projects/attrs/src/attr/_make.py:194: Cannot find link target for "None"
... (truncated 167 lines) ...
pydoctor (https://github.com/twisted/pydoctor): typechecking got 44.08x faster (37.1s -> 0.8s)
(Performance measurements are based on a single noisy sample)
+ Traceback (most recent call last):
+ File "/new_pydoctor/venv/bin/pydoctor", line 8, in <module>
+ sys.exit(main())
+ ^^^^^^
+ File "/new_pydoctor/venv/lib/python3.11/site-packages/pydoctor/driver.py", line 166, in main
+ system = get_system(options)
+ ^^^^^^^^^^^^^^^^^^^
+ File "/new_pydoctor/venv/lib/python3.11/site-packages/pydoctor/driver.py", line 33, in get_system
+ system = options.systemclass(options)
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ File "/new_pydoctor/venv/lib/python3.11/site-packages/pydoctor/model.py", line 975, in __init__
+ extensions.load_extension_module(self, ext)
+ File "/new_pydoctor/venv/lib/python3.11/site-packages/pydoctor/extensions/__init__.py", line 209, in load_extension_module
+ setup_pydoctor_extension(ExtRegistrar(system))
+ File "/new_pydoctor/venv/lib/python3.11/site-packages/pydoctor/extensions/attrs.py", line 608, in setup_pydoctor_extension
+ r.register_mixin(AttrsLikeClass)
+ File "/new_pydoctor/venv/lib/python3.11/site-packages/pydoctor/extensions/__init__.py", line 181, in register_mixin
+ self.system._factory.add_mixins(**_get_mixins(*mixin))
+ ^^^^^^^^^^^^^^^^^^^
+ File "/new_pydoctor/venv/lib/python3.11/site-packages/pydoctor/extensions/__init__.py", line 113, in _get_mixins
+ assert False, f"Invalid mixin {mixin.__name__!r}. Mixins must subclass one of the base class."
+ AssertionError: Invalid mixin 'AttrsLikeClass'. Mixins must subclass one of the base class.
coco (https://github.com/numbbo/coco): typechecking got 43.34x faster (21.8s -> 0.5s)
(Performance measurements are based on a single noisy sample)
+ Traceback (most recent call last):
+ File "/new_pydoctor/venv/bin/pydoctor", line 8, in <module>
+ sys.exit(main())
+ ^^^^^^
+ File "/new_pydoctor/venv/lib/python3.11/site-packages/pydoctor/driver.py", line 166, in main
+ system = get_system(options)
+ ^^^^^^^^^^^^^^^^^^^
+ File "/new_pydoctor/venv/lib/python3.11/site-packages/pydoctor/driver.py", line 33, in get_system
+ system = options.systemclass(options)
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ File "/new_pydoctor/venv/lib/python3.11/site-packages/pydoctor/model.py", line 975, in __init__
+ extensions.load_extension_module(self, ext)
+ File "/new_pydoctor/venv/lib/python3.11/site-packages/pydoctor/extensions/__init__.py", line 209, in load_extension_module
+ setup_pydoctor_extension(ExtRegistrar(system))
+ File "/new_pydoctor/venv/lib/python3.11/site-packages/pydoctor/extensions/attrs.py", line 608, in setup_pydoctor_extension
+ r.register_mixin(AttrsLikeClass)
+ File "/new_pydoctor/venv/lib/python3.11/site-packages/pydoctor/extensions/__init__.py", line 181, in register_mixin
+ self.system._factory.add_mixins(**_get_mixins(*mixin))
+ ^^^^^^^^^^^^^^^^^^^
+ File "/new_pydoctor/venv/lib/python3.11/site-packages/pydoctor/extensions/__init__.py", line 113, in _get_mixins
+ assert False, f"Invalid mixin {mixin.__name__!r}. Mixins must subclass one of the base class."
+ AssertionError: Invalid mixin 'AttrsLikeClass'. Mixins must subclass one of the base class.
- /projects/coco/code-postprocessing/cocopp/findfiles.py:5: bad docstring: No role entry for "file" in module "docutils.parsers.rst.languages.en".
- Trying "file" as canonical role name.
- /projects/coco/code-postprocessing/cocopp/findfiles.py:5: bad docstring: Unknown interpreted text role "file".
- /projects/coco/code-postprocessing/cocopp/findfiles.py:8: bad docstring: No role entry for "file" in module "docutils.parsers.rst.languages.en".
- Trying "file" as canonical role name.
- /projects/coco/code-postprocessing/cocopp/findfiles.py:8: bad docstring: Unknown interpreted text role "file".
- /projects/coco/code-postprocessing/cocopp/findfiles.py:8: bad docstring: No role entry for "file" in module "docutils.parsers.rst.languages.en".
- Trying "file" as canonical role name.
- /projects/coco/code-postprocessing/cocopp/findfiles.py:8: bad docstring: Unknown interpreted text role "file".
- /projects/coco/code-postprocessing/cocopp/pproc.py:676: bad docstring: Unexpected indentation.
- /projects/coco/code-postprocessing/cocopp/pproc.py:677: bad docstring: Block quote ends without a blank line; unexpected unindent.
- /projects/coco/code-postprocessing/cocopp/ppfigdim.py:31: bad docstring: No directive entry for "plot" in module "docutils.parsers.rst.languages.en".
- Trying "plot" as canonical directive name.
- /projects/coco/code-postprocessing/cocopp/ppfigdim.py:31: bad docstring: Unknown directive type "plot"... plot::
- :width: 50%
-
- import urllib
- import tarfile
- import glob
- from pylab import *
-
- import cocopp
-
- # Collect and unarchive data (3.4MB)
- dataurl = 'http://coco.lri.fr/BBOB2009/pythondata/BIPOP-CMA-ES.tar.gz'
- filename, headers = urllib.urlretrieve(dataurl)
- archivefile = tarfile.open(filename)
- archivefile.extractall()
-
- # Scaling figure
- ds = cocopp.load(glob.glob('BBOB2009pythondata/BIPOP-CMA-ES/ppdata_f002_*.pickle'))
- figure()
- cocopp.ppfigdim.plot(ds)
- cocopp.ppfigdim.beautify()
- cocopp.ppfigdim.plot_previous_algorithms(2, False) # plot BBOB 2009 best algorithm on fun 2
- /projects/coco/code-postprocessing/cocopp/pprldistr.py:19: bad docstring: No directive entry for "plot" in module "docutils.parsers.rst.languages.en".
- Trying "plot" as canonical directive name.
- /projects/coco/code-postprocessing/cocopp/pprldistr.py:19: bad docstring: Unknown directive type "plot"... plot::
- :width: 75%
-
- import urllib
- import tarfile
- import glob
- from pylab import *
- import cocopp
-
- # Collect and unarchive data (3.4MB)
- dataurl = 'http://coco.lri.fr/BBOB2009/pythondata/BIPOP-CMA-ES.tar.gz'
- filename, headers = urllib.urlretrieve(dataurl)
- archivefile = tarfile.open(filename)
- archivefile.extractall()
-
- # Empirical cumulative distribution function figure
- ds = cocopp.load(glob.glob('BBOB2009pythondata/BIPOP-CMA-ES/ppdata_f0*_20.pickle'))
- figure()
- cocopp.pprldistr.plot(ds)
- cocopp.pprldistr.beautify() # resize the window to view whole figure
-
- /projects/coco/code-postprocessing/cocopp/compall/pprldmany.py:19: bad docstring: No directive entry for "plot" in module "docutils.parsers.rst.languages.en".
- Trying "plot" as canonical directive name.
- /projects/coco/code-postprocessing/cocopp/compall/pprldmany.py:19: bad docstring: Unknown directive type "plot"... plot::
- :width: 50%
-
- import cocopp
-
- # Empirical cumulative distribution function of bootstrapped ERT figure
- ds = cocopp.load(cocopp.bbob.get('2009/BIPOP-CMA-ES'))
- figure()
- cocopp.compall.pprldmany.plot(ds) # must rather call main instead of plot?
- cocopp.compall.pprldmany.beautify()
- /projects/coco/code-postprocessing/cocopp/rungeneric1.py:7: bad docstring: No role entry for "file" in module "docutils.parsers.rst.languages.en".
- Trying "file" as canonical role name.
- /projects/coco/code-postprocessing/cocopp/rungeneric1.py:7: bad docstring: Unknown interpreted text role "file".
- /projects/coco/code-postprocessing/cocopp/ppfigcons1.py:7: bad docstring: Unexpected indentation.
- /projects/coco/code-postprocessing/cocopp/algportfolio.py:15: bad docstring: No directive entry for "plot" in module "docutils.parsers.rst.languages.en".
- Trying "plot" as canonical directive name.
- /projects/coco/code-postprocessing/cocopp/algportfolio.py:15: bad docstring: Unknown directive type "plot"... plot::
- :width: 75%
-
- import glob
- from pylab import *
- import pickle
- import cocopp
- import cocopp.compall.pprldmany
- import cocopp.algportfolio
-
- # Collect and unarchive data
- dsets = {}
- for alg in ('BIPOP-CMA-ES_hansen_noiseless', 'NEWUOA_ros_noiseless'):
- dsets[alg] = cocopp.load(cocopp.bbob(alg))
-
- # Generate the algorithm portfolio
- dspf = cocopp.algportfolio.build(dsets)
- dsets['Portfolio'] = dspf # store the portfolio in dsets
-
- # plot the run lengths distribution functions
- plt.figure()
- for algname, ds in dsets.items():
- dataset = ds.dictByDimFunc()[10][13] # DataSet dimension 10 on F13
- cocopp.compall.pprldmany.plot(dataset, label=algname)
- cocopp.compall.pprldmany.beautify()
- legend(loc='best') # Display legend
- plt.show()
-
- /projects/coco/code-postprocessing/cocopp/compall/ppperfprof.py:9: bad docstring: No directive entry for "plot" in module "docutils.parsers.rst.languages.en".
- Trying "plot" as canonical directive name.
- /projects/coco/code-postprocessing/cocopp/compall/ppperfprof.py:9: bad docstring: Unknown directive type "plot"... plot::
- :width: 75%
-
- import urllib
- import tarfile
- import glob
- from pylab import *
- import pickle
- import cocopp
- import cocopp.compall.ppperfprof
- import cocopp.bestalg
-
- # Collect and unarchive data
- dsets = {}
- for alg in cocopp.compall.ppperfprof.best:
- for date in ('2010', '2009'):
- try:
- dataurl = 'http://coco.lri.fr/BBOB'+date+'/pythondata/' + alg + '.tar.gz'
- filename, headers = urllib.urlretrieve(dataurl)
- archivefile = tarfile.open(filename)
- archivefile.extractall() # write to disc
- dsets[alg] = cocopp.load(glob.glob('BBOB'+date+'pythondata/' + alg + '/ppdata_f0*_20.pickle'))
- except:
- pass
-
- # plot the profiles
- figure()
- # cocopp.compall.ppperfprof.plotmultiple(dsets, dsref=cocopp.bestalg.bestAlgorithmEntries)
- /projects/coco/code-postprocessing/cocopp/findfiles.py:45: bad docstring: No role entry for "file" in module "docutils.parsers.rst.languages.en".
- Trying "file" as canonical role name.
- /projects/coco/code-postprocessing/cocopp/findfiles.py:45: bad docstring: Unknown interpreted text role "file".
- /projects/coco/code-postprocessing/cocopp/findfiles.py:45: bad docstring: No role entry for "file" in module "docutils.parsers.rst.languages.en".
- Trying "file" as canonical role name.
- /projects/coco/code-postprocessing/cocopp/findfiles.py:45: bad docstring: Unknown interpreted text role "file".
- /projects/coco/code-postprocessing/cocopp/toolsstats.py:985: bad docstring: Unknown target name: "list".
- /projects/coco/code-postprocessing/cocopp/ppfig.py:631: bad docstring: Blank line missing before literal block (after the "::")? Interpreted as a definition list item.
- /projects/coco/code-postprocessing/cocopp/pproc.py:149: bad docstring: Unexpected indentation.
- /projects/coco/code-postprocessing/cocopp/pproc.py:147: bad docstring: Inline literal start-string without end-string.
- /projects/coco/code-postprocessing/cocopp/pproc.py:3241: bad docstring: No role entry for "file" in module "docutils.parsers.rst.languages.en".
- Trying "file" as canonical role name.
- /projects/coco/code-postprocessing/cocopp/pproc.py:3241: bad docstring: Unknown interpreted text role "file".
- /projects/coco/code-postprocessing/cocopp/pproc.py:3241: bad docstring: No role entry for "file" in module "docutils.parsers.rst.languages.en".
- Trying "file" as canonical role name.
- /projects/coco/code-postprocessing/cocopp/pproc.py:3241: bad docstring: Unknown interpreted text role "file".
... (truncated 459 lines) ...
pycma (https://github.com/CMA-ES/pycma): typechecking got 57.23x faster (39.4s -> 0.7s)
(Performance measurements are based on a single noisy sample)
+ Traceback (most recent call last):
+ File "/new_pydoctor/venv/bin/pydoctor", line 8, in <module>
+ sys.exit(main())
+ ^^^^^^
+ File "/new_pydoctor/venv/lib/python3.11/site-packages/pydoctor/driver.py", line 166, in main
+ system = get_system(options)
+ ^^^^^^^^^^^^^^^^^^^
+ File "/new_pydoctor/venv/lib/python3.11/site-packages/pydoctor/driver.py", line 33, in get_system
+ system = options.systemclass(options)
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ File "/new_pydoctor/venv/lib/python3.11/site-packages/pydoctor/model.py", line 975, in __init__
+ extensions.load_extension_module(self, ext)
+ File "/new_pydoctor/venv/lib/python3.11/site-packages/pydoctor/extensions/__init__.py", line 209, in load_extension_module
+ setup_pydoctor_extension(ExtRegistrar(system))
+ File "/new_pydoctor/venv/lib/python3.11/site-packages/pydoctor/extensions/attrs.py", line 608, in setup_pydoctor_extension
+ r.register_mixin(AttrsLikeClass)
... (truncated 1160 lines) ...``` |
Looks like I messed up with the merge commit… |
This PR drastically improve our understanding of attrs generated classes.
It will infer the
__init__
signature and present fields docstrings in the parameter table.It understand combinations of auto_attribs, auto_detect, kw_only and init arguments to the attr.s() function. As well as the new APIs attrs.define(). For attr.ib(), it checks the converter, factory, default, type, kw_only and init arguments to infer each constructor param.
It only handles the creation of the
__init__
method, it’s does not create__eq__
and other attrs methods. Since these methods all have the same signature, it’s probably not worth it to actually create Function instance to represent them. One thing we could do it to add a note at the end of the docstring listing implemented methods. Another thing to do would be to show the class decorators so the reader can determine whether all compare methods are implemented.See documentation here: https://pydoctor--656.org.readthedocs.build/en/656/codedoc.html#using-attrs