libv8 6.7.288.46.1 → 7.3.492.27.0beta1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (408) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +3 -0
  3. data/CHANGELOG.md +4 -0
  4. data/README.md +2 -0
  5. data/ext/libv8/builder.rb +6 -2
  6. data/lib/libv8/version.rb +1 -1
  7. data/vendor/depot_tools/.gitattributes +1 -0
  8. data/vendor/depot_tools/.gitignore +7 -0
  9. data/vendor/depot_tools/CROS_OWNERS +5 -0
  10. data/vendor/depot_tools/OWNERS +12 -1
  11. data/vendor/depot_tools/PRESUBMIT.py +16 -9
  12. data/vendor/depot_tools/README.md +9 -2
  13. data/vendor/depot_tools/autoninja +14 -6
  14. data/vendor/depot_tools/autoninja.bat +11 -1
  15. data/vendor/depot_tools/autoninja.py +40 -18
  16. data/vendor/depot_tools/bb +12 -0
  17. data/vendor/depot_tools/bb.bat +7 -0
  18. data/vendor/depot_tools/bootstrap/win/manifest.txt +1 -1
  19. data/vendor/depot_tools/bootstrap/win/manifest_bleeding_edge.txt +1 -1
  20. data/vendor/depot_tools/bootstrap/win/win_tools.py +2 -1
  21. data/vendor/depot_tools/buildbucket.py +57 -4
  22. data/vendor/depot_tools/cipd +157 -44
  23. data/vendor/depot_tools/cipd.bat +51 -14
  24. data/vendor/depot_tools/cipd.ps1 +104 -42
  25. data/vendor/depot_tools/cipd_client_version +1 -1
  26. data/vendor/depot_tools/cipd_client_version.digests +21 -0
  27. data/vendor/depot_tools/cipd_manifest.txt +19 -6
  28. data/vendor/depot_tools/cipd_manifest.versions +318 -0
  29. data/vendor/depot_tools/clang_format.py +4 -4
  30. data/vendor/depot_tools/cpplint.py +44 -199
  31. data/vendor/depot_tools/dart_format.py +2 -2
  32. data/vendor/depot_tools/detect_host_arch.py +8 -3
  33. data/vendor/depot_tools/download_from_google_storage.py +47 -39
  34. data/vendor/depot_tools/fetch.py +30 -18
  35. data/vendor/depot_tools/fetch_configs/android_internal.py +34 -0
  36. data/vendor/depot_tools/fetch_configs/chromium.py +18 -1
  37. data/vendor/depot_tools/fetch_configs/config_util.py +4 -2
  38. data/vendor/depot_tools/fetch_configs/inspector_protocol.py +40 -0
  39. data/vendor/depot_tools/fetch_configs/node-ci.py +41 -0
  40. data/vendor/depot_tools/fix_encoding.py +3 -3
  41. data/vendor/depot_tools/gclient +1 -1
  42. data/vendor/depot_tools/gclient.py +415 -198
  43. data/vendor/depot_tools/gclient_eval.py +220 -171
  44. data/vendor/depot_tools/gclient_paths.py +142 -0
  45. data/vendor/depot_tools/gclient_scm.py +200 -51
  46. data/vendor/depot_tools/gclient_utils.py +88 -191
  47. data/vendor/depot_tools/gerrit_client.py +13 -0
  48. data/vendor/depot_tools/gerrit_util.py +158 -23
  49. data/vendor/depot_tools/git-nav-upstream +1 -1
  50. data/vendor/depot_tools/git_cache.py +77 -24
  51. data/vendor/depot_tools/git_cl.py +705 -1099
  52. data/vendor/depot_tools/git_common.py +9 -6
  53. data/vendor/depot_tools/git_map_branches.py +19 -2
  54. data/vendor/depot_tools/git_nav_downstream.py +3 -4
  55. data/vendor/depot_tools/git_rebase_update.py +14 -0
  56. data/vendor/depot_tools/git_reparent_branch.py +8 -2
  57. data/vendor/depot_tools/gn.py +38 -3
  58. data/vendor/depot_tools/gsutil.py +8 -3
  59. data/vendor/depot_tools/gsutil.py.bat +15 -0
  60. data/vendor/depot_tools/gsutil.vpython +16 -0
  61. data/vendor/depot_tools/infra/config/OWNERS +0 -1
  62. data/vendor/depot_tools/infra/config/recipes.cfg +3 -2
  63. data/vendor/depot_tools/lucicfg +12 -0
  64. data/vendor/depot_tools/lucicfg.bat +7 -0
  65. data/vendor/depot_tools/man/html/git-map-branches.html +34 -2
  66. data/vendor/depot_tools/man/html/git-new-branch.html +40 -32
  67. data/vendor/depot_tools/man/man1/git-map-branches.1 +24 -5
  68. data/vendor/depot_tools/man/man1/git-new-branch.1 +35 -27
  69. data/vendor/depot_tools/man/src/git-map-branches.demo.1.sh +1 -0
  70. data/vendor/depot_tools/man/src/git-map-branches.txt +10 -0
  71. data/vendor/depot_tools/man/src/git-new-branch.demo.1.sh +9 -4
  72. data/vendor/depot_tools/man/src/git-new-branch.txt +1 -1
  73. data/vendor/depot_tools/metrics.README.md +98 -0
  74. data/vendor/depot_tools/metrics.py +296 -0
  75. data/vendor/depot_tools/metrics_utils.py +303 -0
  76. data/vendor/depot_tools/my_activity.py +91 -29
  77. data/vendor/depot_tools/ninja +1 -1
  78. data/vendor/depot_tools/ninjalog.README.md +64 -0
  79. data/vendor/depot_tools/ninjalog_uploader.py +232 -0
  80. data/vendor/depot_tools/ninjalog_uploader_wrapper.py +116 -0
  81. data/vendor/depot_tools/owners.py +30 -13
  82. data/vendor/depot_tools/owners_finder.py +5 -2
  83. data/vendor/depot_tools/presubmit_canned_checks.py +188 -29
  84. data/vendor/depot_tools/presubmit_support.py +18 -41
  85. data/vendor/depot_tools/pylintrc +23 -19
  86. data/vendor/depot_tools/recipes/OWNERS +2 -0
  87. data/vendor/depot_tools/recipes/README.recipes.md +344 -151
  88. data/vendor/depot_tools/recipes/recipe_modules/bot_update/OWNERS +2 -0
  89. data/vendor/depot_tools/recipes/recipe_modules/bot_update/__init__.py +2 -16
  90. data/vendor/depot_tools/recipes/recipe_modules/bot_update/api.py +141 -99
  91. data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/basic.json +5 -8
  92. data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/basic_luci.json +5 -8
  93. data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/basic_with_branch_heads.json +6 -98
  94. data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/clobber.json +4 -9
  95. data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/deprecated_got_revision_mapping.json +45 -5
  96. data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/gerrit_no_rebase_patch_ref.json +4 -9
  97. data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/gerrit_no_reset.json +4 -9
  98. data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/{tryjob.json → input_commit_with_id_without_repo.json} +6 -11
  99. data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/{tryjob_empty_revision.json → multiple_patch_refs.json} +8 -9
  100. data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/no_apply_patch_on_gclient.json +19 -29
  101. data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/{trychange.json → refs.json} +4 -9
  102. data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/reset_root_solution_revision.json +4 -9
  103. data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/tryjob_fail.json +51 -6
  104. data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/tryjob_fail_patch.json +50 -6
  105. data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/tryjob_fail_patch_download.json +51 -6
  106. data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/tryjob_gerrit_angle.json +17 -25
  107. data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/tryjob_gerrit_branch_heads.json +17 -25
  108. data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/tryjob_gerrit_feature_branch.json +18 -26
  109. data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/tryjob_gerrit_v8_feature_branch.json +18 -26
  110. data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/tryjob_gerrit_webrtc.json +26 -28
  111. data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/tryjob_v8.json +45 -5
  112. data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/tryjob_v8_head_by_default.json +17 -25
  113. data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/unrecognized_commit_repo.json +13 -0
  114. data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/with_manifest_name.json +13 -152
  115. data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/with_tags.json +4 -9
  116. data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.py +185 -202
  117. data/vendor/depot_tools/recipes/recipe_modules/bot_update/resources/bot_update.py +52 -157
  118. data/vendor/depot_tools/recipes/recipe_modules/bot_update/test_api.py +5 -14
  119. data/vendor/depot_tools/recipes/recipe_modules/bot_update/tests/ensure_checkout.py +34 -0
  120. data/vendor/depot_tools/recipes/recipe_modules/cipd/api.py +14 -2
  121. data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/full.expected/basic.json +4 -5
  122. data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/full.expected/basic_pkg.json +4 -5
  123. data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/full.expected/describe-failed.json +7 -5
  124. data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/full.expected/describe-many-instances.json +4 -5
  125. data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/full.expected/mac64.json +4 -5
  126. data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/full.expected/pkg_bad_file.json +9 -3
  127. data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/full.expected/pkg_bad_mode.json +9 -3
  128. data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/full.expected/pkg_bad_verfile.json +9 -3
  129. data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/full.expected/win64.json +4 -5
  130. data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/platform_suffix.expected/junk arch.json +2 -3
  131. data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/platform_suffix.expected/junk bits.json +2 -3
  132. data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/platform_suffix.expected/linux_arm_32.json +2 -3
  133. data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/platform_suffix.expected/linux_arm_64.json +2 -3
  134. data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/platform_suffix.expected/linux_intel_32.json +2 -3
  135. data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/platform_suffix.expected/linux_intel_64.json +2 -3
  136. data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/platform_suffix.expected/linux_mips_64.json +2 -3
  137. data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/platform_suffix.expected/mac_intel_64.json +2 -3
  138. data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/platform_suffix.expected/win_intel_32.json +2 -3
  139. data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/platform_suffix.expected/win_intel_64.json +2 -3
  140. data/vendor/depot_tools/recipes/recipe_modules/depot_tools/api.py +13 -8
  141. data/vendor/depot_tools/recipes/recipe_modules/depot_tools/examples/full.expected/basic.json +18 -12
  142. data/vendor/depot_tools/recipes/recipe_modules/depot_tools/examples/full.expected/basic_luci.json +18 -12
  143. data/vendor/depot_tools/recipes/recipe_modules/depot_tools/examples/full.expected/win.json +18 -12
  144. data/vendor/depot_tools/recipes/recipe_modules/depot_tools/examples/full.py +3 -0
  145. data/vendor/depot_tools/recipes/recipe_modules/gclient/__init__.py +1 -0
  146. data/vendor/depot_tools/recipes/recipe_modules/gclient/api.py +58 -46
  147. data/vendor/depot_tools/recipes/recipe_modules/gclient/config.py +65 -22
  148. data/vendor/depot_tools/recipes/recipe_modules/gclient/examples/full.expected/basic.json +20 -21
  149. data/vendor/depot_tools/recipes/recipe_modules/gclient/examples/full.expected/buildbot.json +20 -21
  150. data/vendor/depot_tools/recipes/recipe_modules/gclient/examples/full.expected/revision.json +20 -21
  151. data/vendor/depot_tools/recipes/recipe_modules/gclient/examples/full.expected/tryserver.json +20 -21
  152. data/vendor/depot_tools/recipes/recipe_modules/gclient/examples/full.py +5 -2
  153. data/vendor/depot_tools/recipes/recipe_modules/gclient/tests/patch_project.py +62 -14
  154. data/vendor/depot_tools/recipes/recipe_modules/gerrit/api.py +24 -38
  155. data/vendor/depot_tools/recipes/recipe_modules/gerrit/examples/full.expected/basic.json +56 -50
  156. data/vendor/depot_tools/recipes/recipe_modules/gerrit/examples/full.py +15 -9
  157. data/vendor/depot_tools/recipes/recipe_modules/git/__init__.py +4 -1
  158. data/vendor/depot_tools/recipes/recipe_modules/git/api.py +34 -22
  159. data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/basic.json +5 -6
  160. data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/basic_branch.json +5 -6
  161. data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/basic_file_name.json +5 -6
  162. data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/basic_hash.json +5 -6
  163. data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/basic_luci.json +222 -0
  164. data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/basic_ref.json +5 -6
  165. data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/basic_submodule_update_force.json +5 -6
  166. data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/basic_tags.json +224 -0
  167. data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/can_fail_build.json +10 -6
  168. data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/cannot_fail_build.json +5 -7
  169. data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/cat-file_test.json +5 -6
  170. data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/count-objects_delta.json +5 -6
  171. data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/count-objects_failed.json +5 -7
  172. data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/count-objects_with_bad_output.json +5 -6
  173. data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/count-objects_with_bad_output_fails_build.json +10 -5
  174. data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/curl_trace_file.json +5 -6
  175. data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/git-cache-checkout.json +8 -9
  176. data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/platform_win.json +5 -6
  177. data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/rebase_failed.json +12 -8
  178. data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/remote_not_origin.json +5 -6
  179. data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/set_got_revision.json +5 -6
  180. data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.py +27 -11
  181. data/vendor/depot_tools/recipes/recipe_modules/git_cl/api.py +1 -1
  182. data/vendor/depot_tools/recipes/recipe_modules/git_cl/examples/full.expected/basic.json +12 -13
  183. data/vendor/depot_tools/recipes/recipe_modules/gitiles/__init__.py +5 -0
  184. data/vendor/depot_tools/recipes/recipe_modules/gitiles/api.py +120 -5
  185. data/vendor/depot_tools/recipes/recipe_modules/gitiles/examples/full.expected/basic.json +45 -3
  186. data/vendor/depot_tools/recipes/recipe_modules/gitiles/examples/full.py +25 -0
  187. data/vendor/depot_tools/recipes/recipe_modules/gitiles/resources/gerrit_client.py +56 -4
  188. data/vendor/depot_tools/recipes/recipe_modules/gitiles/tests/parse_repo_url.expected/basic.json +6 -0
  189. data/vendor/depot_tools/recipes/recipe_modules/gitiles/tests/parse_repo_url.py +49 -0
  190. data/vendor/depot_tools/recipes/recipe_modules/gsutil/api.py +24 -13
  191. data/vendor/depot_tools/recipes/recipe_modules/gsutil/examples/full.expected/basic.json +13 -14
  192. data/vendor/depot_tools/recipes/recipe_modules/infra_paths/examples/full.expected/basic.json +2 -3
  193. data/vendor/depot_tools/recipes/recipe_modules/infra_paths/examples/full.expected/paths_buildbot_linux.json +2 -3
  194. data/vendor/depot_tools/recipes/recipe_modules/infra_paths/examples/full.expected/paths_buildbot_mac.json +2 -3
  195. data/vendor/depot_tools/recipes/recipe_modules/infra_paths/examples/full.expected/paths_buildbot_win.json +2 -3
  196. data/vendor/depot_tools/recipes/recipe_modules/infra_paths/examples/full.expected/paths_generic_linux.json +2 -3
  197. data/vendor/depot_tools/recipes/recipe_modules/infra_paths/examples/full.expected/paths_generic_mac.json +2 -3
  198. data/vendor/depot_tools/recipes/recipe_modules/infra_paths/examples/full.expected/paths_generic_win.json +2 -3
  199. data/vendor/depot_tools/recipes/recipe_modules/infra_paths/examples/full.expected/paths_kitchen_linux.json +2 -3
  200. data/vendor/depot_tools/recipes/recipe_modules/infra_paths/examples/full.expected/paths_kitchen_mac.json +2 -3
  201. data/vendor/depot_tools/recipes/recipe_modules/infra_paths/examples/full.expected/paths_kitchen_win.json +2 -3
  202. data/vendor/depot_tools/recipes/recipe_modules/infra_paths/path_config.py +1 -2
  203. data/vendor/depot_tools/recipes/recipe_modules/osx_sdk/__init__.py +35 -0
  204. data/vendor/depot_tools/recipes/recipe_modules/osx_sdk/api.py +116 -0
  205. data/vendor/depot_tools/recipes/recipe_modules/osx_sdk/examples/full.expected/linux.json +22 -0
  206. data/vendor/depot_tools/recipes/recipe_modules/osx_sdk/examples/full.expected/mac.json +82 -0
  207. data/vendor/depot_tools/recipes/recipe_modules/osx_sdk/examples/full.expected/win.json +22 -0
  208. data/vendor/depot_tools/recipes/recipe_modules/osx_sdk/examples/full.py +23 -0
  209. data/vendor/depot_tools/recipes/recipe_modules/presubmit/__init__.py +1 -0
  210. data/vendor/depot_tools/recipes/recipe_modules/presubmit/api.py +2 -7
  211. data/vendor/depot_tools/recipes/recipe_modules/presubmit/examples/full.expected/basic.json +7 -6
  212. data/vendor/depot_tools/recipes/recipe_modules/tryserver/__init__.py +1 -0
  213. data/vendor/depot_tools/recipes/recipe_modules/tryserver/api.py +117 -8
  214. data/vendor/depot_tools/recipes/recipe_modules/tryserver/examples/full.expected/basic_tags.json +4 -5
  215. data/vendor/depot_tools/recipes/recipe_modules/tryserver/examples/full.expected/set_failure_hash_with_no_steps.json +7 -4
  216. data/vendor/depot_tools/recipes/recipe_modules/tryserver/examples/full.expected/with_gerrit_patch.json +98 -7
  217. data/vendor/depot_tools/recipes/recipe_modules/tryserver/examples/full.expected/with_gerrit_patch_and_target_ref.json +147 -0
  218. data/vendor/depot_tools/recipes/recipe_modules/tryserver/examples/full.expected/with_git_patch.json +8 -5
  219. data/vendor/depot_tools/recipes/recipe_modules/tryserver/examples/full.expected/with_git_patch_luci.json +8 -5
  220. data/vendor/depot_tools/recipes/recipe_modules/tryserver/examples/full.expected/with_wrong_patch.json +9 -6
  221. data/vendor/depot_tools/recipes/recipe_modules/tryserver/examples/full.expected/with_wrong_patch_new.json +9 -6
  222. data/vendor/depot_tools/recipes/recipe_modules/tryserver/examples/full.py +27 -2
  223. data/vendor/depot_tools/recipes/recipe_modules/tryserver/test_api.py +14 -0
  224. data/vendor/depot_tools/recipes/recipe_modules/windows_sdk/__init__.py +25 -0
  225. data/vendor/depot_tools/recipes/recipe_modules/windows_sdk/api.py +137 -0
  226. data/vendor/depot_tools/recipes/recipe_modules/windows_sdk/examples/full.expected/linux.json +22 -0
  227. data/vendor/depot_tools/recipes/recipe_modules/windows_sdk/examples/full.expected/mac.json +22 -0
  228. data/vendor/depot_tools/recipes/recipe_modules/windows_sdk/examples/full.expected/win.json +107 -0
  229. data/vendor/depot_tools/recipes/recipe_modules/windows_sdk/examples/full.py +26 -0
  230. data/vendor/depot_tools/recipes/recipes.py +37 -27
  231. data/vendor/depot_tools/recipes/recipes/fetch_end_to_end_test.expected/basic.json +7 -10
  232. data/vendor/depot_tools/repo +34 -8
  233. data/vendor/depot_tools/roll_dep.py +52 -49
  234. data/vendor/depot_tools/scm.py +38 -23
  235. data/vendor/depot_tools/setup_color.py +4 -2
  236. data/vendor/depot_tools/split_cl.py +32 -4
  237. data/vendor/depot_tools/subprocess2.py +22 -4
  238. data/vendor/depot_tools/third_party/httplib2/README.chromium +2 -2
  239. data/vendor/depot_tools/third_party/httplib2/__init__.py +242 -158
  240. data/vendor/depot_tools/third_party/httplib2/cacerts.txt +57 -44
  241. data/vendor/depot_tools/third_party/httplib2/socks.py +15 -5
  242. data/vendor/depot_tools/third_party/logilab/README.chromium +2 -4
  243. data/vendor/depot_tools/third_party/logilab/astroid/README.chromium +2 -1
  244. data/vendor/depot_tools/third_party/logilab/astroid/__init__.py +10 -5
  245. data/vendor/depot_tools/third_party/logilab/astroid/__pkginfo__.py +5 -5
  246. data/vendor/depot_tools/third_party/logilab/astroid/arguments.py +233 -0
  247. data/vendor/depot_tools/third_party/logilab/astroid/as_string.py +82 -33
  248. data/vendor/depot_tools/third_party/logilab/astroid/bases.py +137 -153
  249. data/vendor/depot_tools/third_party/logilab/astroid/brain/{builtin_inference.py → brain_builtin_inference.py} +117 -26
  250. data/vendor/depot_tools/third_party/logilab/astroid/brain/brain_dateutil.py +15 -0
  251. data/vendor/depot_tools/third_party/logilab/astroid/brain/{py2gi.py → brain_gi.py} +48 -8
  252. data/vendor/depot_tools/third_party/logilab/astroid/brain/{py2mechanize.py → brain_mechanize.py} +0 -0
  253. data/vendor/depot_tools/third_party/logilab/astroid/brain/{pynose.py → brain_nose.py} +4 -1
  254. data/vendor/depot_tools/third_party/logilab/astroid/brain/brain_numpy.py +62 -0
  255. data/vendor/depot_tools/third_party/logilab/astroid/brain/brain_pytest.py +76 -0
  256. data/vendor/depot_tools/third_party/logilab/astroid/brain/brain_qt.py +44 -0
  257. data/vendor/depot_tools/third_party/logilab/astroid/brain/{pysix_moves.py → brain_six.py} +28 -1
  258. data/vendor/depot_tools/third_party/logilab/astroid/brain/brain_ssl.py +65 -0
  259. data/vendor/depot_tools/third_party/logilab/astroid/brain/brain_stdlib.py +473 -0
  260. data/vendor/depot_tools/third_party/logilab/astroid/builder.py +104 -81
  261. data/vendor/depot_tools/third_party/logilab/astroid/context.py +81 -0
  262. data/vendor/depot_tools/third_party/logilab/astroid/decorators.py +75 -0
  263. data/vendor/depot_tools/third_party/logilab/astroid/exceptions.py +20 -0
  264. data/vendor/depot_tools/third_party/logilab/astroid/inference.py +137 -183
  265. data/vendor/depot_tools/third_party/logilab/astroid/manager.py +45 -169
  266. data/vendor/depot_tools/third_party/logilab/astroid/mixins.py +37 -14
  267. data/vendor/depot_tools/third_party/logilab/astroid/modutils.py +112 -41
  268. data/vendor/depot_tools/third_party/logilab/astroid/node_classes.py +243 -156
  269. data/vendor/depot_tools/third_party/logilab/astroid/nodes.py +35 -22
  270. data/vendor/depot_tools/third_party/logilab/astroid/objects.py +186 -0
  271. data/vendor/depot_tools/third_party/logilab/astroid/protocols.py +157 -102
  272. data/vendor/depot_tools/third_party/logilab/astroid/raw_building.py +32 -8
  273. data/vendor/depot_tools/third_party/logilab/astroid/rebuilder.py +372 -309
  274. data/vendor/depot_tools/third_party/logilab/astroid/scoped_nodes.py +652 -420
  275. data/vendor/depot_tools/third_party/logilab/astroid/test_utils.py +4 -21
  276. data/vendor/depot_tools/third_party/logilab/astroid/transforms.py +96 -0
  277. data/vendor/depot_tools/third_party/logilab/astroid/util.py +89 -0
  278. data/vendor/depot_tools/third_party/logilab/lazy_object_proxy/LICENSE +19 -0
  279. data/vendor/depot_tools/third_party/logilab/lazy_object_proxy/README.chromium +11 -0
  280. data/vendor/depot_tools/third_party/logilab/lazy_object_proxy/__init__.py +20 -0
  281. data/vendor/depot_tools/third_party/logilab/lazy_object_proxy/cext.c +1421 -0
  282. data/vendor/depot_tools/third_party/logilab/lazy_object_proxy/compat.py +9 -0
  283. data/vendor/depot_tools/third_party/logilab/lazy_object_proxy/simple.py +246 -0
  284. data/vendor/depot_tools/third_party/logilab/lazy_object_proxy/slots.py +414 -0
  285. data/vendor/depot_tools/third_party/logilab/lazy_object_proxy/utils.py +13 -0
  286. data/vendor/depot_tools/third_party/logilab/wrapt/LICENSE +24 -0
  287. data/vendor/depot_tools/third_party/logilab/wrapt/README.chromium +11 -0
  288. data/vendor/depot_tools/third_party/logilab/wrapt/__init__.py +19 -0
  289. data/vendor/depot_tools/third_party/logilab/wrapt/_wrappers.c +2729 -0
  290. data/vendor/depot_tools/third_party/logilab/wrapt/arguments.py +96 -0
  291. data/vendor/depot_tools/third_party/logilab/wrapt/decorators.py +512 -0
  292. data/vendor/depot_tools/third_party/logilab/wrapt/importer.py +228 -0
  293. data/vendor/depot_tools/third_party/logilab/wrapt/wrappers.py +901 -0
  294. data/vendor/depot_tools/third_party/pylint/README.chromium +2 -25
  295. data/vendor/depot_tools/third_party/pylint/__pkginfo__.py +13 -3
  296. data/vendor/depot_tools/third_party/pylint/checkers/__init__.py +1 -2
  297. data/vendor/depot_tools/third_party/pylint/checkers/async.py +82 -0
  298. data/vendor/depot_tools/third_party/pylint/checkers/base.py +893 -119
  299. data/vendor/depot_tools/third_party/pylint/checkers/classes.py +342 -204
  300. data/vendor/depot_tools/third_party/pylint/checkers/design_analysis.py +51 -34
  301. data/vendor/depot_tools/third_party/pylint/checkers/exceptions.py +84 -47
  302. data/vendor/depot_tools/third_party/pylint/checkers/format.py +55 -30
  303. data/vendor/depot_tools/third_party/pylint/checkers/imports.py +314 -73
  304. data/vendor/depot_tools/third_party/pylint/checkers/logging.py +10 -8
  305. data/vendor/depot_tools/third_party/pylint/checkers/misc.py +2 -1
  306. data/vendor/depot_tools/third_party/pylint/checkers/newstyle.py +45 -48
  307. data/vendor/depot_tools/third_party/pylint/checkers/python3.py +31 -21
  308. data/vendor/depot_tools/third_party/pylint/checkers/raw_metrics.py +3 -3
  309. data/vendor/depot_tools/third_party/pylint/checkers/similar.py +4 -5
  310. data/vendor/depot_tools/third_party/pylint/checkers/spelling.py +24 -10
  311. data/vendor/depot_tools/third_party/pylint/checkers/stdlib.py +120 -56
  312. data/vendor/depot_tools/third_party/pylint/checkers/strings.py +38 -35
  313. data/vendor/depot_tools/third_party/pylint/checkers/typecheck.py +485 -138
  314. data/vendor/depot_tools/third_party/pylint/checkers/utils.py +319 -142
  315. data/vendor/depot_tools/third_party/pylint/checkers/variables.py +329 -207
  316. data/vendor/depot_tools/third_party/pylint/config.py +739 -76
  317. data/vendor/depot_tools/third_party/pylint/epylint.py +9 -5
  318. data/vendor/depot_tools/third_party/pylint/extensions/__init__.py +0 -0
  319. data/vendor/depot_tools/third_party/pylint/extensions/check_docs.py +311 -0
  320. data/vendor/depot_tools/third_party/pylint/extensions/check_elif.py +62 -0
  321. data/vendor/depot_tools/third_party/{logilab/common → pylint}/graph.py +30 -133
  322. data/vendor/depot_tools/third_party/pylint/gui.py +2 -2
  323. data/vendor/depot_tools/third_party/pylint/interfaces.py +21 -3
  324. data/vendor/depot_tools/third_party/pylint/lint.py +123 -140
  325. data/vendor/depot_tools/third_party/pylint/pyreverse/diadefslib.py +10 -13
  326. data/vendor/depot_tools/third_party/pylint/pyreverse/diagrams.py +15 -4
  327. data/vendor/depot_tools/third_party/pylint/pyreverse/inspector.py +372 -0
  328. data/vendor/depot_tools/third_party/pylint/pyreverse/main.py +30 -7
  329. data/vendor/depot_tools/third_party/pylint/pyreverse/utils.py +80 -2
  330. data/vendor/depot_tools/third_party/{logilab/common → pylint/pyreverse}/vcgutils.py +19 -37
  331. data/vendor/depot_tools/third_party/pylint/pyreverse/writer.py +3 -4
  332. data/vendor/depot_tools/third_party/pylint/reporters/__init__.py +34 -18
  333. data/vendor/depot_tools/third_party/pylint/reporters/guireporter.py +1 -1
  334. data/vendor/depot_tools/third_party/pylint/reporters/html.py +10 -3
  335. data/vendor/depot_tools/third_party/pylint/reporters/json.py +10 -4
  336. data/vendor/depot_tools/third_party/pylint/reporters/text.py +94 -3
  337. data/vendor/depot_tools/third_party/pylint/reporters/ureports/__init__.py +106 -0
  338. data/vendor/depot_tools/third_party/{logilab/common → pylint/reporters}/ureports/html_writer.py +17 -57
  339. data/vendor/depot_tools/third_party/{logilab/common → pylint/reporters}/ureports/nodes.py +52 -74
  340. data/vendor/depot_tools/third_party/{logilab/common → pylint/reporters}/ureports/text_writer.py +14 -60
  341. data/vendor/depot_tools/third_party/pylint/testutils.py +22 -20
  342. data/vendor/depot_tools/third_party/pylint/utils.py +268 -44
  343. data/vendor/depot_tools/third_party/repo/progress.py +42 -0
  344. data/vendor/depot_tools/update_depot_tools +1 -1
  345. data/vendor/depot_tools/upload_metrics.py +25 -0
  346. data/vendor/depot_tools/win_toolchain/get_toolchain_if_necessary.py +45 -15
  347. data/vendor/depot_tools/win_toolchain/package_from_installed.py +71 -24
  348. data/vendor/depot_tools/yapf +1 -1
  349. data/vendor/depot_tools/yapf.bat +1 -1
  350. metadata +92 -77
  351. data/vendor/depot_tools/git-crsync +0 -3
  352. data/vendor/depot_tools/infra/config/cq.cfg +0 -32
  353. data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/apply_gerrit_ref.json +0 -29
  354. data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/apply_gerrit_ref_custom.json +0 -29
  355. data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/buildbot.json +0 -105
  356. data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/shallow.json +0 -195
  357. data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/tryjob_gerrit_angle_deprecated.json +0 -248
  358. data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/tryjob_gerrit_v8.json +0 -248
  359. data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/with_manifest_name_no_patch.json +0 -105
  360. data/vendor/depot_tools/recipes/recipe_modules/bot_update/resources/apply_gerrit.py +0 -33
  361. data/vendor/depot_tools/third_party/logilab/astroid/brain/py2pytest.py +0 -31
  362. data/vendor/depot_tools/third_party/logilab/astroid/brain/py2qt4.py +0 -22
  363. data/vendor/depot_tools/third_party/logilab/astroid/brain/py2stdlib.py +0 -334
  364. data/vendor/depot_tools/third_party/logilab/astroid/inspector.py +0 -273
  365. data/vendor/depot_tools/third_party/logilab/astroid/utils.py +0 -239
  366. data/vendor/depot_tools/third_party/logilab/common/LICENSE.txt +0 -339
  367. data/vendor/depot_tools/third_party/logilab/common/README.chromium +0 -11
  368. data/vendor/depot_tools/third_party/logilab/common/__init__.py +0 -175
  369. data/vendor/depot_tools/third_party/logilab/common/__pkginfo__.py +0 -57
  370. data/vendor/depot_tools/third_party/logilab/common/cache.py +0 -114
  371. data/vendor/depot_tools/third_party/logilab/common/changelog.py +0 -238
  372. data/vendor/depot_tools/third_party/logilab/common/clcommands.py +0 -334
  373. data/vendor/depot_tools/third_party/logilab/common/cli.py +0 -211
  374. data/vendor/depot_tools/third_party/logilab/common/compat.py +0 -78
  375. data/vendor/depot_tools/third_party/logilab/common/configuration.py +0 -1105
  376. data/vendor/depot_tools/third_party/logilab/common/contexts.py +0 -5
  377. data/vendor/depot_tools/third_party/logilab/common/corbautils.py +0 -117
  378. data/vendor/depot_tools/third_party/logilab/common/daemon.py +0 -101
  379. data/vendor/depot_tools/third_party/logilab/common/date.py +0 -335
  380. data/vendor/depot_tools/third_party/logilab/common/dbf.py +0 -231
  381. data/vendor/depot_tools/third_party/logilab/common/debugger.py +0 -214
  382. data/vendor/depot_tools/third_party/logilab/common/decorators.py +0 -281
  383. data/vendor/depot_tools/third_party/logilab/common/deprecation.py +0 -189
  384. data/vendor/depot_tools/third_party/logilab/common/fileutils.py +0 -404
  385. data/vendor/depot_tools/third_party/logilab/common/interface.py +0 -71
  386. data/vendor/depot_tools/third_party/logilab/common/logging_ext.py +0 -195
  387. data/vendor/depot_tools/third_party/logilab/common/modutils.py +0 -702
  388. data/vendor/depot_tools/third_party/logilab/common/optik_ext.py +0 -392
  389. data/vendor/depot_tools/third_party/logilab/common/optparser.py +0 -92
  390. data/vendor/depot_tools/third_party/logilab/common/proc.py +0 -277
  391. data/vendor/depot_tools/third_party/logilab/common/pyro_ext.py +0 -180
  392. data/vendor/depot_tools/third_party/logilab/common/pytest.py +0 -1199
  393. data/vendor/depot_tools/third_party/logilab/common/registry.py +0 -1119
  394. data/vendor/depot_tools/third_party/logilab/common/shellutils.py +0 -462
  395. data/vendor/depot_tools/third_party/logilab/common/sphinx_ext.py +0 -87
  396. data/vendor/depot_tools/third_party/logilab/common/sphinxutils.py +0 -122
  397. data/vendor/depot_tools/third_party/logilab/common/table.py +0 -929
  398. data/vendor/depot_tools/third_party/logilab/common/tasksqueue.py +0 -101
  399. data/vendor/depot_tools/third_party/logilab/common/testlib.py +0 -1392
  400. data/vendor/depot_tools/third_party/logilab/common/textutils.py +0 -537
  401. data/vendor/depot_tools/third_party/logilab/common/tree.py +0 -369
  402. data/vendor/depot_tools/third_party/logilab/common/umessage.py +0 -194
  403. data/vendor/depot_tools/third_party/logilab/common/ureports/__init__.py +0 -172
  404. data/vendor/depot_tools/third_party/logilab/common/ureports/docbook_writer.py +0 -140
  405. data/vendor/depot_tools/third_party/logilab/common/urllib2ext.py +0 -89
  406. data/vendor/depot_tools/third_party/logilab/common/visitor.py +0 -109
  407. data/vendor/depot_tools/third_party/logilab/common/xmlrpcutils.py +0 -131
  408. data/vendor/depot_tools/third_party/logilab/common/xmlutils.py +0 -61
@@ -20,30 +20,68 @@ from __future__ import generators
20
20
  import sys
21
21
  from collections import defaultdict
22
22
 
23
+ import six
24
+
23
25
  import astroid
24
- from astroid import YES, Instance, are_exclusive, AssAttr, Class
25
26
  from astroid.bases import Generator, BUILTINS
26
- from astroid.inference import InferenceContext
27
-
27
+ from astroid.exceptions import InconsistentMroError, DuplicateBasesError
28
+ from astroid import objects
29
+ from astroid.scoped_nodes import function_to_method
28
30
  from pylint.interfaces import IAstroidChecker
29
31
  from pylint.checkers import BaseChecker
30
32
  from pylint.checkers.utils import (
31
- PYMETHODS, overrides_a_method, check_messages, is_attr_private,
32
- is_attr_protected, node_frame_class, safe_infer, is_builtin_object,
33
- decorated_with_property, unimplemented_abstract_methods)
34
- import six
33
+ PYMETHODS, SPECIAL_METHODS_PARAMS,
34
+ overrides_a_method, check_messages, is_attr_private,
35
+ is_attr_protected, node_frame_class, is_builtin_object,
36
+ decorated_with_property, unimplemented_abstract_methods,
37
+ decorated_with, class_is_abstract,
38
+ safe_infer, has_known_bases)
39
+ from pylint.utils import deprecated_option, get_global_option
40
+
35
41
 
36
42
  if sys.version_info >= (3, 0):
37
43
  NEXT_METHOD = '__next__'
38
44
  else:
39
45
  NEXT_METHOD = 'next'
40
46
  ITER_METHODS = ('__iter__', '__getitem__')
47
+ INVALID_BASE_CLASSES = {'bool', 'range', 'slice', 'memoryview'}
48
+
49
+
50
+ def _get_method_args(method):
51
+ args = method.args.args
52
+ if method.type in ('classmethod', 'method'):
53
+ return len(args) - 1
54
+ return len(args)
55
+
56
+
57
+ def _is_invalid_base_class(cls):
58
+ return cls.name in INVALID_BASE_CLASSES and is_builtin_object(cls)
59
+
60
+
61
+ def _has_data_descriptor(cls, attr):
62
+ attributes = cls.getattr(attr)
63
+ for attribute in attributes:
64
+ try:
65
+ for inferred in attribute.infer():
66
+ if isinstance(inferred, astroid.Instance):
67
+ try:
68
+ inferred.getattr('__get__')
69
+ inferred.getattr('__set__')
70
+ except astroid.NotFoundError:
71
+ continue
72
+ else:
73
+ return True
74
+ except astroid.InferenceError:
75
+ # Can't infer, avoid emitting a false positive in this case.
76
+ return True
77
+ return False
78
+
41
79
 
42
80
  def _called_in_methods(func, klass, methods):
43
81
  """ Check if the func was called in any of the given methods,
44
82
  belonging to the *klass*. Returns True if so, False otherwise.
45
83
  """
46
- if not isinstance(func, astroid.Function):
84
+ if not isinstance(func, astroid.FunctionDef):
47
85
  return False
48
86
  for method in methods:
49
87
  try:
@@ -51,7 +89,7 @@ def _called_in_methods(func, klass, methods):
51
89
  except astroid.NotFoundError:
52
90
  continue
53
91
  for infer_method in infered:
54
- for callfunc in infer_method.nodes_of_class(astroid.CallFunc):
92
+ for callfunc in infer_method.nodes_of_class(astroid.Call):
55
93
  try:
56
94
  bound = next(callfunc.func.infer())
57
95
  except (astroid.InferenceError, StopIteration):
@@ -65,15 +103,6 @@ def _called_in_methods(func, klass, methods):
65
103
  return True
66
104
  return False
67
105
 
68
- def class_is_abstract(node):
69
- """return true if the given class node should be considered as an abstract
70
- class
71
- """
72
- for method in node.methods():
73
- if method.parent.frame() is node:
74
- if method.is_abstract(pass_is_abstract=False):
75
- return True
76
- return False
77
106
 
78
107
  def _is_attribute_property(name, klass):
79
108
  """ Check if the given attribute *name* is a property
@@ -96,13 +125,43 @@ def _is_attribute_property(name, klass):
96
125
  infered = next(attr.infer())
97
126
  except astroid.InferenceError:
98
127
  continue
99
- if (isinstance(infered, astroid.Function) and
128
+ if (isinstance(infered, astroid.FunctionDef) and
100
129
  decorated_with_property(infered)):
101
130
  return True
102
131
  if infered.pytype() == property_name:
103
132
  return True
104
133
  return False
105
134
 
135
+ def _has_bare_super_call(fundef_node):
136
+ for call in fundef_node.nodes_of_class(astroid.Call):
137
+ func = call.func
138
+ if (isinstance(func, astroid.Name) and
139
+ func.name == 'super' and
140
+ not call.args):
141
+ return True
142
+ return False
143
+
144
+ def _safe_infer_call_result(node, caller, context=None):
145
+ """
146
+ Safely infer the return value of a function.
147
+
148
+ Returns None if inference failed or if there is some ambiguity (more than
149
+ one node has been inferred). Otherwise returns infered value.
150
+ """
151
+ try:
152
+ inferit = node.infer_call_result(caller, context=context)
153
+ value = next(inferit)
154
+ except astroid.InferenceError:
155
+ return # inference failed
156
+ except StopIteration:
157
+ return # no values infered
158
+ try:
159
+ next(inferit)
160
+ return # there is ambiguity on the inferred node
161
+ except astroid.InferenceError:
162
+ return # there is some kind of ambiguity
163
+ except StopIteration:
164
+ return value
106
165
 
107
166
  MSGS = {
108
167
  'F0202': ('Unable to check methods signature (%s / %s)',
@@ -170,15 +229,6 @@ MSGS = {
170
229
  'Used when a method doesn\'t use its bound instance, and so could '
171
230
  'be written as a function.'
172
231
  ),
173
-
174
- 'E0221': ('Interface resolved to %s is not a class',
175
- 'interface-is-not-class',
176
- 'Used when a class claims to implement an interface which is not '
177
- 'a class.'),
178
- 'E0222': ('Missing method %r from %s interface',
179
- 'missing-interface-method',
180
- 'Used when a method declared in an interface is missing from a '
181
- 'class implementing this interface'),
182
232
  'W0221': ('Arguments number differs from %s %r method',
183
233
  'arguments-differ',
184
234
  'Used when a method has a different number of arguments than in '
@@ -192,12 +242,6 @@ MSGS = {
192
242
  'Used when an abstract method (i.e. raise NotImplementedError) is '
193
243
  'not overridden in concrete class.'
194
244
  ),
195
- 'F0220': ('failed to resolve interfaces implemented by %s (%s)',
196
- 'unresolved-interface',
197
- 'Used when a Pylint as failed to find interfaces implemented by '
198
- ' a class'),
199
-
200
-
201
245
  'W0231': ('__init__ method from base class %r is not called',
202
246
  'super-init-not-called',
203
247
  'Used when an ancestor class method has an __init__ method '
@@ -210,15 +254,6 @@ MSGS = {
210
254
  'non-parent-init-called',
211
255
  'Used when an __init__ method is called on a class which is not '
212
256
  'in the direct ancestors for the analysed class.'),
213
- 'W0234': ('__iter__ returns non-iterator',
214
- 'non-iterator-returned',
215
- 'Used when an __iter__ method returns something which is not an '
216
- 'iterable (i.e. has no `%s` method)' % NEXT_METHOD),
217
- 'E0235': ('__exit__ must accept 3 arguments: type, value, traceback',
218
- 'bad-context-manager',
219
- 'Used when the __exit__ special method, belonging to a '
220
- 'context manager, does not accept 3 arguments '
221
- '(type, value, traceback).'),
222
257
  'E0236': ('Invalid object %r in __slots__, must contain '
223
258
  'only non empty strings',
224
259
  'invalid-slots-object',
@@ -235,8 +270,20 @@ MSGS = {
235
270
  'inherit-non-class',
236
271
  'Used when a class inherits from something which is not a '
237
272
  'class.'),
238
-
239
-
273
+ 'E0240': ('Inconsistent method resolution order for class %r',
274
+ 'inconsistent-mro',
275
+ 'Used when a class has an inconsistent method resolutin order.'),
276
+ 'E0241': ('Duplicate bases for class %r',
277
+ 'duplicate-bases',
278
+ 'Used when a class has duplicate bases.'),
279
+ 'R0202': ('Consider using a decorator instead of calling classmethod',
280
+ 'no-classmethod-decorator',
281
+ 'Used when a class method is defined without using the decorator '
282
+ 'syntax.'),
283
+ 'R0203': ('Consider using a decorator instead of calling staticmethod',
284
+ 'no-staticmethod-decorator',
285
+ 'Used when a static method is defined without using the decorator '
286
+ 'syntax.'),
240
287
  }
241
288
 
242
289
 
@@ -246,7 +293,6 @@ class ClassChecker(BaseChecker):
246
293
  * overridden methods signature
247
294
  * access only to existent members via self
248
295
  * attributes not defined in the __init__ method
249
- * supported interfaces implementation
250
296
  * unreachable code
251
297
  """
252
298
 
@@ -259,21 +305,10 @@ class ClassChecker(BaseChecker):
259
305
  priority = -2
260
306
  # configuration options
261
307
  options = (('ignore-iface-methods',
262
- {'default' : (#zope interface
263
- 'isImplementedBy', 'deferred', 'extends', 'names',
264
- 'namesAndDescriptions', 'queryDescriptionFor', 'getBases',
265
- 'getDescriptionFor', 'getDoc', 'getName', 'getTaggedValue',
266
- 'getTaggedValueTags', 'isEqualOrExtendedBy', 'setTaggedValue',
267
- 'isImplementedByInstancesOf',
268
- # twisted
269
- 'adaptWith',
270
- # logilab.common interface
271
- 'is_implemented_by'),
272
- 'type' : 'csv',
273
- 'metavar' : '<method names>',
274
- 'help' : 'List of interface methods to ignore, \
275
- separated by a comma. This is used for instance to not check methods defines \
276
- in Zope\'s Interface base class.'}
308
+ # TODO(cpopa): remove this in Pylint 1.6.
309
+ deprecated_option(opt_type="csv",
310
+ help_msg="This is deprecated, because "
311
+ "it is not used anymore.")
277
312
  ),
278
313
  ('defining-attr-methods',
279
314
  {'default' : ('__init__', '__new__', 'setUp'),
@@ -313,22 +348,33 @@ a metaclass class method.'}
313
348
  self._first_attrs = []
314
349
  self._meth_could_be_func = None
315
350
 
316
- def visit_class(self, node):
317
- """init visit variable _accessed and check interfaces
351
+ def visit_classdef(self, node):
352
+ """init visit variable _accessed
318
353
  """
319
354
  self._accessed.append(defaultdict(list))
320
355
  self._check_bases_classes(node)
321
- self._check_interfaces(node)
322
- # if not an interface, exception, metaclass
323
- if node.type == 'class':
356
+ # if not an exception or a metaclass
357
+ if node.type == 'class' and has_known_bases(node):
324
358
  try:
325
359
  node.local_attr('__init__')
326
360
  except astroid.NotFoundError:
327
361
  self.add_message('no-init', args=node, node=node)
328
362
  self._check_slots(node)
329
363
  self._check_proper_bases(node)
364
+ self._check_consistent_mro(node)
365
+
366
+ def _check_consistent_mro(self, node):
367
+ """Detect that a class has a consistent mro or duplicate bases."""
368
+ try:
369
+ node.mro()
370
+ except InconsistentMroError:
371
+ self.add_message('inconsistent-mro', args=node.name, node=node)
372
+ except DuplicateBasesError:
373
+ self.add_message('duplicate-bases', args=node.name, node=node)
374
+ except NotImplementedError:
375
+ # Old style class, there's no mro so don't do anything.
376
+ pass
330
377
 
331
- @check_messages('inherit-non-class')
332
378
  def _check_proper_bases(self, node):
333
379
  """
334
380
  Detect that a class inherits something which is not
@@ -336,23 +382,31 @@ a metaclass class method.'}
336
382
  """
337
383
  for base in node.bases:
338
384
  ancestor = safe_infer(base)
339
- if ancestor in (YES, None):
385
+ if ancestor in (astroid.YES, None):
340
386
  continue
341
387
  if (isinstance(ancestor, astroid.Instance) and
342
388
  ancestor.is_subtype_of('%s.type' % (BUILTINS,))):
343
389
  continue
344
- if not isinstance(ancestor, astroid.Class):
390
+
391
+ if (not isinstance(ancestor, astroid.ClassDef) or
392
+ _is_invalid_base_class(ancestor)):
345
393
  self.add_message('inherit-non-class',
346
394
  args=base.as_string(), node=node)
347
395
 
348
- @check_messages('access-member-before-definition',
349
- 'attribute-defined-outside-init')
350
- def leave_class(self, cnode):
396
+ def leave_classdef(self, cnode):
351
397
  """close a class node:
352
398
  check that instance attributes are defined in __init__ and check
353
399
  access to existent members
354
400
  """
355
401
  # check access to existent members on non metaclass classes
402
+ ignore_mixins = get_global_option(self, 'ignore-mixin-members',
403
+ default=True)
404
+ if ignore_mixins and cnode.name[-5:].lower() == 'mixin':
405
+ # We are in a mixin class. No need to try to figure out if
406
+ # something is missing, since it is most likely that it will
407
+ # miss.
408
+ return
409
+
356
410
  accessed = self._accessed.pop()
357
411
  if cnode.type != 'metaclass':
358
412
  self._check_accessed_members(cnode, accessed)
@@ -400,7 +454,7 @@ a metaclass class method.'}
400
454
  self.add_message('attribute-defined-outside-init',
401
455
  args=attr, node=node)
402
456
 
403
- def visit_function(self, node):
457
+ def visit_functiondef(self, node):
404
458
  """check method arguments, overriding"""
405
459
  # ignore actual functions
406
460
  if not node.is_method():
@@ -422,13 +476,13 @@ a metaclass class method.'}
422
476
  # dictionary.
423
477
  # This may happen with astroid build from living objects
424
478
  continue
425
- if not isinstance(meth_node, astroid.Function):
479
+ if not isinstance(meth_node, astroid.FunctionDef):
426
480
  continue
427
- self._check_signature(node, meth_node, 'overridden')
481
+ self._check_signature(node, meth_node, 'overridden', klass)
428
482
  break
429
483
  if node.decorators:
430
484
  for decorator in node.decorators.nodes:
431
- if isinstance(decorator, astroid.Getattr) and \
485
+ if isinstance(decorator, astroid.Attribute) and \
432
486
  decorator.attrname in ('getter', 'setter', 'deleter'):
433
487
  # attribute affectation will call this method, not hiding it
434
488
  return
@@ -440,21 +494,17 @@ a metaclass class method.'}
440
494
  try:
441
495
  overridden = klass.instance_attr(node.name)[0] # XXX
442
496
  overridden_frame = overridden.frame()
443
- if (isinstance(overridden_frame, astroid.Function)
497
+ if (isinstance(overridden_frame, astroid.FunctionDef)
444
498
  and overridden_frame.type == 'method'):
445
499
  overridden_frame = overridden_frame.parent.frame()
446
- if (isinstance(overridden_frame, Class)
500
+ if (isinstance(overridden_frame, astroid.ClassDef)
447
501
  and klass.is_subtype_of(overridden_frame.qname())):
448
502
  args = (overridden.root().name, overridden.fromlineno)
449
503
  self.add_message('method-hidden', args=args, node=node)
450
504
  except astroid.NotFoundError:
451
505
  pass
452
506
 
453
- # check non-iterators in __iter__
454
- if node.name == '__iter__':
455
- self._check_iter(node)
456
- elif node.name == '__exit__':
457
- self._check_exit(node)
507
+ visit_asyncfunctiondef = visit_functiondef
458
508
 
459
509
  def _check_slots(self, node):
460
510
  if '__slots__' not in node.locals:
@@ -482,7 +532,7 @@ a metaclass class method.'}
482
532
  values = [item[0] for item in slots.items]
483
533
  else:
484
534
  values = slots.itered()
485
- if values is YES:
535
+ if values is astroid.YES:
486
536
  return
487
537
 
488
538
  for elt in values:
@@ -493,7 +543,7 @@ a metaclass class method.'}
493
543
 
494
544
  def _check_slots_elt(self, elt):
495
545
  for infered in elt.infer():
496
- if infered is YES:
546
+ if infered is astroid.YES:
497
547
  continue
498
548
  if (not isinstance(infered, astroid.Const) or
499
549
  not isinstance(infered.value, six.string_types)):
@@ -506,39 +556,11 @@ a metaclass class method.'}
506
556
  args=infered.as_string(),
507
557
  node=elt)
508
558
 
509
- def _check_iter(self, node):
510
- try:
511
- infered = node.infer_call_result(node)
512
- except astroid.InferenceError:
513
- return
514
-
515
- for infered_node in infered:
516
- if (infered_node is YES
517
- or isinstance(infered_node, Generator)):
518
- continue
519
- if isinstance(infered_node, astroid.Instance):
520
- try:
521
- infered_node.local_attr(NEXT_METHOD)
522
- except astroid.NotFoundError:
523
- self.add_message('non-iterator-returned',
524
- node=node)
525
- break
526
-
527
- def _check_exit(self, node):
528
- positional = sum(1 for arg in node.args.args if arg.name != 'self')
529
- if positional < 3 and not node.args.vararg:
530
- self.add_message('bad-context-manager',
531
- node=node)
532
- elif positional > 3:
533
- self.add_message('bad-context-manager',
534
- node=node)
535
-
536
- def leave_function(self, node):
559
+ def leave_functiondef(self, node):
537
560
  """on method node, check if this method couldn't be a function
538
561
 
539
562
  ignore class, static and abstract methods, initializer,
540
- methods overridden from a parent class and any
541
- kind of method defined in an interface for this warning
563
+ methods overridden from a parent class.
542
564
  """
543
565
  if node.is_method():
544
566
  if node.args.args is not None:
@@ -547,13 +569,14 @@ a metaclass class method.'}
547
569
  return
548
570
  class_node = node.parent.frame()
549
571
  if (self._meth_could_be_func and node.type == 'method'
550
- and not node.name in PYMETHODS
572
+ and node.name not in PYMETHODS
551
573
  and not (node.is_abstract() or
552
- overrides_a_method(class_node, node.name))
553
- and class_node.type != 'interface'):
574
+ overrides_a_method(class_node, node.name) or
575
+ decorated_with_property(node) or
576
+ (six.PY3 and _has_bare_super_call(node)))):
554
577
  self.add_message('no-self-use', node=node)
555
578
 
556
- def visit_getattr(self, node):
579
+ def visit_attribute(self, node):
557
580
  """check if the getattr is an access to a class member
558
581
  if so, register it. Also check for access to protected
559
582
  class member from outside its class (but ignore __special__
@@ -569,8 +592,8 @@ a metaclass class method.'}
569
592
 
570
593
  self._check_protected_attribute_access(node)
571
594
 
572
- def visit_assattr(self, node):
573
- if isinstance(node.ass_type(), astroid.AugAssign) and self.is_first_attr(node):
595
+ def visit_assignattr(self, node):
596
+ if isinstance(node.assign_type(), astroid.AugAssign) and self.is_first_attr(node):
574
597
  self._accessed[-1][node.attrname].append(node)
575
598
  self._check_in_slots(node)
576
599
 
@@ -579,7 +602,7 @@ a metaclass class method.'}
579
602
  is defined in the class slots.
580
603
  """
581
604
  infered = safe_infer(node.expr)
582
- if infered and isinstance(infered, Instance):
605
+ if infered and isinstance(infered, astroid.Instance):
583
606
  klass = infered._proxied
584
607
  if '__slots__' not in klass.locals or not klass.newstyle:
585
608
  return
@@ -602,20 +625,60 @@ a metaclass class method.'}
602
625
  # Properties circumvent the slots mechanism,
603
626
  # so we should not emit a warning for them.
604
627
  return
628
+ if (node.attrname in klass.locals
629
+ and _has_data_descriptor(klass, node.attrname)):
630
+ # Descriptors circumvent the slots mechanism as well.
631
+ return
605
632
  self.add_message('assigning-non-slot',
606
633
  args=(node.attrname, ), node=node)
607
634
 
608
- @check_messages('protected-access')
635
+ @check_messages('protected-access', 'no-classmethod-decorator',
636
+ 'no-staticmethod-decorator')
609
637
  def visit_assign(self, assign_node):
638
+ self._check_classmethod_declaration(assign_node)
610
639
  node = assign_node.targets[0]
611
- if not isinstance(node, AssAttr):
640
+ if not isinstance(node, astroid.AssignAttr):
612
641
  return
613
642
 
614
643
  if self.is_first_attr(node):
615
644
  return
616
-
617
645
  self._check_protected_attribute_access(node)
618
646
 
647
+ def _check_classmethod_declaration(self, node):
648
+ """Checks for uses of classmethod() or staticmethod()
649
+
650
+ When a @classmethod or @staticmethod decorator should be used instead.
651
+ A message will be emitted only if the assignment is at a class scope
652
+ and only if the classmethod's argument belongs to the class where it
653
+ is defined.
654
+ `node` is an assign node.
655
+ """
656
+ if not isinstance(node.value, astroid.Call):
657
+ return
658
+
659
+ # check the function called is "classmethod" or "staticmethod"
660
+ func = node.value.func
661
+ if (not isinstance(func, astroid.Name) or
662
+ func.name not in ('classmethod', 'staticmethod')):
663
+ return
664
+
665
+ msg = ('no-classmethod-decorator' if func.name == 'classmethod' else
666
+ 'no-staticmethod-decorator')
667
+ # assignment must be at a class scope
668
+ parent_class = node.scope()
669
+ if not isinstance(parent_class, astroid.ClassDef):
670
+ return
671
+
672
+ # Check if the arg passed to classmethod is a class member
673
+ classmeth_arg = node.value.args[0]
674
+ if not isinstance(classmeth_arg, astroid.Name):
675
+ return
676
+
677
+ method_name = classmeth_arg.name
678
+ if any(method_name == member.name
679
+ for member in parent_class.mymethods()):
680
+ self.add_message(msg, node=node.targets[0])
681
+
619
682
  def _check_protected_attribute_access(self, node):
620
683
  '''Given an attribute access node (set or get), check if attribute
621
684
  access is legitimate. Call _check_first_attr with node before calling
@@ -644,7 +707,7 @@ a metaclass class method.'}
644
707
  return
645
708
 
646
709
  # If the expression begins with a call to super, that's ok.
647
- if isinstance(node.expr, astroid.CallFunc) and \
710
+ if isinstance(node.expr, astroid.Call) and \
648
711
  isinstance(node.expr.func, astroid.Name) and \
649
712
  node.expr.func.name == 'super':
650
713
  return
@@ -659,16 +722,13 @@ a metaclass class method.'}
659
722
  # b = property(lambda: self._b)
660
723
 
661
724
  stmt = node.parent.statement()
662
- try:
663
- if (isinstance(stmt, astroid.Assign) and
664
- (stmt in klass.body or klass.parent_of(stmt)) and
665
- isinstance(stmt.value, astroid.CallFunc) and
666
- isinstance(stmt.value.func, astroid.Name) and
667
- stmt.value.func.name == 'property' and
668
- is_builtin_object(next(stmt.value.func.infer(), None))):
725
+ if (isinstance(stmt, astroid.Assign)
726
+ and len(stmt.targets) == 1
727
+ and isinstance(stmt.targets[0], astroid.AssignName)):
728
+ name = stmt.targets[0].name
729
+ if _is_attribute_property(name, klass):
669
730
  return
670
- except astroid.InferenceError:
671
- pass
731
+
672
732
  self.add_message('protected-access', node=node, args=attrname)
673
733
 
674
734
  def visit_name(self, node):
@@ -682,9 +742,8 @@ a metaclass class method.'}
682
742
  def _check_accessed_members(self, node, accessed):
683
743
  """check that accessed members are defined"""
684
744
  # XXX refactor, probably much simpler now that E0201 is in type checker
745
+ excs = ('AttributeError', 'Exception', 'BaseException')
685
746
  for attr, nodes in six.iteritems(accessed):
686
- # deactivate "except doesn't do anything", that's expected
687
- # pylint: disable=W0704
688
747
  try:
689
748
  # is it a class attribute ?
690
749
  node.local_attr(attr)
@@ -726,8 +785,7 @@ a metaclass class method.'}
726
785
  lno = defstmt.fromlineno
727
786
  for _node in nodes:
728
787
  if _node.frame() is frame and _node.fromlineno < lno \
729
- and not are_exclusive(_node.statement(), defstmt,
730
- ('AttributeError', 'Exception', 'BaseException')):
788
+ and not astroid.are_exclusive(_node.statement(), defstmt, excs):
731
789
  self.add_message('access-member-before-definition',
732
790
  node=_node, args=(attr, lno))
733
791
 
@@ -823,55 +881,6 @@ a metaclass class method.'}
823
881
  self.add_message('abstract-method', node=node,
824
882
  args=(name, owner.name))
825
883
 
826
- def _check_interfaces(self, node):
827
- """check that the given class node really implements declared
828
- interfaces
829
- """
830
- e0221_hack = [False]
831
- def iface_handler(obj):
832
- """filter interface objects, it should be classes"""
833
- if not isinstance(obj, astroid.Class):
834
- e0221_hack[0] = True
835
- self.add_message('interface-is-not-class', node=node,
836
- args=(obj.as_string(),))
837
- return False
838
- return True
839
- ignore_iface_methods = self.config.ignore_iface_methods
840
- try:
841
- for iface in node.interfaces(handler_func=iface_handler):
842
- for imethod in iface.methods():
843
- name = imethod.name
844
- if name.startswith('_') or name in ignore_iface_methods:
845
- # don't check method beginning with an underscore,
846
- # usually belonging to the interface implementation
847
- continue
848
- # get class method astroid
849
- try:
850
- method = node_method(node, name)
851
- except astroid.NotFoundError:
852
- self.add_message('missing-interface-method',
853
- args=(name, iface.name),
854
- node=node)
855
- continue
856
- # ignore inherited methods
857
- if method.parent.frame() is not node:
858
- continue
859
- # check signature
860
- self._check_signature(method, imethod,
861
- '%s interface' % iface.name)
862
- except astroid.InferenceError:
863
- if e0221_hack[0]:
864
- return
865
- implements = Instance(node).getattr('__implements__')[0]
866
- assignment = implements.parent
867
- assert isinstance(assignment, astroid.Assign)
868
- # assignment.expr can be a Name or a Tuple or whatever.
869
- # Use as_string() for the message
870
- # FIXME: in case of multiple interfaces, find which one could not
871
- # be resolved
872
- self.add_message('unresolved-interface', node=implements,
873
- args=(node.name, assignment.value.as_string()))
874
-
875
884
  def _check_init(self, node):
876
885
  """check that the __init__ method call super or ancestors'__init__
877
886
  method
@@ -882,19 +891,19 @@ a metaclass class method.'}
882
891
  klass_node = node.parent.frame()
883
892
  to_call = _ancestors_to_call(klass_node)
884
893
  not_called_yet = dict(to_call)
885
- for stmt in node.nodes_of_class(astroid.CallFunc):
894
+ for stmt in node.nodes_of_class(astroid.Call):
886
895
  expr = stmt.func
887
- if not isinstance(expr, astroid.Getattr) \
896
+ if not isinstance(expr, astroid.Attribute) \
888
897
  or expr.attrname != '__init__':
889
898
  continue
890
899
  # skip the test if using super
891
- if isinstance(expr.expr, astroid.CallFunc) and \
900
+ if isinstance(expr.expr, astroid.Call) and \
892
901
  isinstance(expr.expr.func, astroid.Name) and \
893
902
  expr.expr.func.name == 'super':
894
903
  return
895
904
  try:
896
905
  for klass in expr.expr.infer():
897
- if klass is YES:
906
+ if klass is astroid.YES:
898
907
  continue
899
908
  # The infered klass can be super(), which was
900
909
  # assigned to a variable and the `__init__`
@@ -904,10 +913,12 @@ a metaclass class method.'}
904
913
  # base.__init__(...)
905
914
 
906
915
  if (isinstance(klass, astroid.Instance) and
907
- isinstance(klass._proxied, astroid.Class) and
916
+ isinstance(klass._proxied, astroid.ClassDef) and
908
917
  is_builtin_object(klass._proxied) and
909
918
  klass._proxied.name == 'super'):
910
919
  return
920
+ elif isinstance(klass, objects.Super):
921
+ return
911
922
  try:
912
923
  del not_called_yet[klass]
913
924
  except KeyError:
@@ -921,25 +932,39 @@ a metaclass class method.'}
921
932
  continue
922
933
  self.add_message('super-init-not-called', args=klass.name, node=node)
923
934
 
924
- def _check_signature(self, method1, refmethod, class_type):
935
+ def _check_signature(self, method1, refmethod, class_type, cls):
925
936
  """check that the signature of the two given methods match
926
-
927
- class_type is in 'class', 'interface'
928
937
  """
929
- if not (isinstance(method1, astroid.Function)
930
- and isinstance(refmethod, astroid.Function)):
938
+ if not (isinstance(method1, astroid.FunctionDef)
939
+ and isinstance(refmethod, astroid.FunctionDef)):
931
940
  self.add_message('method-check-failed',
932
941
  args=(method1, refmethod), node=method1)
933
942
  return
934
- # don't care about functions with unknown argument (builtins)
943
+
944
+ instance = cls.instanciate_class()
945
+ method1 = function_to_method(method1, instance)
946
+ refmethod = function_to_method(refmethod, instance)
947
+
948
+ # Don't care about functions with unknown argument (builtins).
935
949
  if method1.args.args is None or refmethod.args.args is None:
936
950
  return
937
- # if we use *args, **kwargs, skip the below checks
951
+ # If we use *args, **kwargs, skip the below checks.
938
952
  if method1.args.vararg or method1.args.kwarg:
939
953
  return
954
+ # Ignore private to class methods.
940
955
  if is_attr_private(method1.name):
941
956
  return
942
- if len(method1.args.args) != len(refmethod.args.args):
957
+ # Ignore setters, they have an implicit extra argument,
958
+ # which shouldn't be taken in consideration.
959
+ if method1.decorators:
960
+ for decorator in method1.decorators.nodes:
961
+ if (isinstance(decorator, astroid.Attribute) and
962
+ decorator.attrname == 'setter'):
963
+ return
964
+
965
+ method1_args = _get_method_args(method1)
966
+ refmethod_args = _get_method_args(refmethod)
967
+ if method1_args != refmethod_args:
943
968
  self.add_message('arguments-differ',
944
969
  args=(class_type, method1.name),
945
970
  node=method1)
@@ -955,6 +980,118 @@ a metaclass class method.'}
955
980
  return self._first_attrs and isinstance(node.expr, astroid.Name) and \
956
981
  node.expr.name == self._first_attrs[-1]
957
982
 
983
+
984
+ class SpecialMethodsChecker(BaseChecker):
985
+ """Checker which verifies that special methods
986
+ are implemented correctly.
987
+ """
988
+ __implements__ = (IAstroidChecker, )
989
+ name = 'classes'
990
+ msgs = {
991
+ 'E0301': ('__iter__ returns non-iterator',
992
+ 'non-iterator-returned',
993
+ 'Used when an __iter__ method returns something which is not an '
994
+ 'iterable (i.e. has no `%s` method)' % NEXT_METHOD,
995
+ {'old_names': [('W0234', 'non-iterator-returned'),
996
+ ('E0234', 'non-iterator-returned')]}),
997
+ 'E0302': ('The special method %r expects %s param(s), %d %s given',
998
+ 'unexpected-special-method-signature',
999
+ 'Emitted when a special method was defined with an '
1000
+ 'invalid number of parameters. If it has too few or '
1001
+ 'too many, it might not work at all.',
1002
+ {'old_names': [('E0235', 'bad-context-manager')]}),
1003
+ }
1004
+ priority = -2
1005
+
1006
+ @check_messages('unexpected-special-method-signature',
1007
+ 'non-iterator-returned')
1008
+ def visit_functiondef(self, node):
1009
+ if not node.is_method():
1010
+ return
1011
+ if node.name == '__iter__':
1012
+ self._check_iter(node)
1013
+ if node.name in PYMETHODS:
1014
+ self._check_unexpected_method_signature(node)
1015
+
1016
+ visit_asyncfunctiondef = visit_functiondef
1017
+
1018
+ def _check_unexpected_method_signature(self, node):
1019
+ expected_params = SPECIAL_METHODS_PARAMS[node.name]
1020
+
1021
+ if expected_params is None:
1022
+ # This can support a variable number of parameters.
1023
+ return
1024
+ if not len(node.args.args) and not node.args.vararg:
1025
+ # Method has no parameter, will be catched
1026
+ # by no-method-argument.
1027
+ return
1028
+
1029
+ if decorated_with(node, [BUILTINS + ".staticmethod"]):
1030
+ # We expect to not take in consideration self.
1031
+ all_args = node.args.args
1032
+ else:
1033
+ all_args = node.args.args[1:]
1034
+ mandatory = len(all_args) - len(node.args.defaults)
1035
+ optional = len(node.args.defaults)
1036
+ current_params = mandatory + optional
1037
+
1038
+ if isinstance(expected_params, tuple):
1039
+ # The expected number of parameters can be any value from this
1040
+ # tuple, although the user should implement the method
1041
+ # to take all of them in consideration.
1042
+ emit = mandatory not in expected_params
1043
+ expected_params = "between %d or %d" % expected_params
1044
+ else:
1045
+ # If the number of mandatory parameters doesn't
1046
+ # suffice, the expected parameters for this
1047
+ # function will be deduced from the optional
1048
+ # parameters.
1049
+ rest = expected_params - mandatory
1050
+ if rest == 0:
1051
+ emit = False
1052
+ elif rest < 0:
1053
+ emit = True
1054
+ elif rest > 0:
1055
+ emit = not ((optional - rest) >= 0 or node.args.vararg)
1056
+
1057
+ if emit:
1058
+ verb = "was" if current_params <= 1 else "were"
1059
+ self.add_message('unexpected-special-method-signature',
1060
+ args=(node.name, expected_params, current_params, verb),
1061
+ node=node)
1062
+
1063
+ @staticmethod
1064
+ def _is_iterator(node):
1065
+ if node is astroid.YES:
1066
+ # Just ignore YES objects.
1067
+ return True
1068
+ if isinstance(node, Generator):
1069
+ # Generators can be itered.
1070
+ return True
1071
+
1072
+ if isinstance(node, astroid.Instance):
1073
+ try:
1074
+ node.local_attr(NEXT_METHOD)
1075
+ return True
1076
+ except astroid.NotFoundError:
1077
+ pass
1078
+ elif isinstance(node, astroid.ClassDef):
1079
+ metaclass = node.metaclass()
1080
+ if metaclass and isinstance(metaclass, astroid.ClassDef):
1081
+ try:
1082
+ metaclass.local_attr(NEXT_METHOD)
1083
+ return True
1084
+ except astroid.NotFoundError:
1085
+ pass
1086
+ return False
1087
+
1088
+ def _check_iter(self, node):
1089
+ infered = _safe_infer_call_result(node, node)
1090
+ if infered is not None:
1091
+ if not self._is_iterator(infered):
1092
+ self.add_message('non-iterator-returned', node=node)
1093
+
1094
+
958
1095
  def _ancestors_to_call(klass_node, method='__init__'):
959
1096
  """return a dictionary where keys are the list of base classes providing
960
1097
  the queried method, and so that should/may be called from the method node
@@ -972,11 +1109,12 @@ def node_method(node, method_name):
972
1109
  """get astroid for <method_name> on the given class node, ensuring it
973
1110
  is a Function node
974
1111
  """
975
- for n in node.local_attr(method_name):
976
- if isinstance(n, astroid.Function):
977
- return n
1112
+ for node_attr in node.local_attr(method_name):
1113
+ if isinstance(node_attr, astroid.Function):
1114
+ return node_attr
978
1115
  raise astroid.NotFoundError(method_name)
979
1116
 
980
1117
  def register(linter):
981
1118
  """required method to auto register this checker """
982
1119
  linter.register_checker(ClassChecker(linter))
1120
+ linter.register_checker(SpecialMethodsChecker(linter))