--- a/Documentation/Source/eric6.Plugins.CheckerPlugins.CodeStyleChecker.pep8.html Fri Mar 11 19:36:55 2016 +0100 +++ b/Documentation/Source/eric6.Plugins.CheckerPlugins.CodeStyleChecker.pep8.html Fri Mar 11 19:43:23 2016 +0100 @@ -53,6 +53,9 @@ <td><a href="#_add_check">_add_check</a></td> <td></td> </tr><tr> +<td><a href="#_get_parameters">_get_parameters</a></td> +<td></td> +</tr><tr> <td><a href="#_is_eol_token">_is_eol_token</a></td> <td></td> </tr><tr> @@ -62,9 +65,15 @@ <td><a href="#_main">_main</a></td> <td>Parse options and run checks on Python source.</td> </tr><tr> +<td><a href="#_parse_multi_options">_parse_multi_options</a></td> +<td>Split and strip and discard empties.</td> +</tr><tr> <td><a href="#blank_lines">blank_lines</a></td> <td>Separate top-level function and class definitions with two blank lines.</td> </tr><tr> +<td><a href="#break_around_binary_operator">break_around_binary_operator</a></td> +<td>Avoid breaks before binary operators.</td> +</tr><tr> <td><a href="#comparison_negative">comparison_negative</a></td> <td>Negative comparison should be done using "not in" and "is not".</td> </tr><tr> @@ -104,6 +113,12 @@ <td><a href="#init_checks_registry">init_checks_registry</a></td> <td>Register all globally visible functions.</td> </tr><tr> +<td><a href="#is_binary_operator">is_binary_operator</a></td> +<td></td> +</tr><tr> +<td><a href="#is_string_literal">is_string_literal</a></td> +<td></td> +</tr><tr> <td><a href="#maximum_line_length">maximum_line_length</a></td> <td>Limit all lines to a maximum of 79 characters.</td> </tr><tr> @@ -113,6 +128,9 @@ <td><a href="#missing_whitespace_around_operator">missing_whitespace_around_operator</a></td> <td>Surround operators with a single space on either side.</td> </tr><tr> +<td><a href="#module_imports_on_top_of_file">module_imports_on_top_of_file</a></td> +<td>Imports are always put at the top of the file, just after any module comments and docstrings, and before module globals and constants.</td> +</tr><tr> <td><a href="#mute_string">mute_string</a></td> <td>Replace contents with 'xxx' to prevent syntax matching.</td> </tr><tr> @@ -138,7 +156,7 @@ <td>When raising an exception, use "raise ValueError('message')".</td> </tr><tr> <td><a href="#read_config">read_config</a></td> -<td>Read both user configuration and local configuration.</td> +<td>Read and parse configurations</td> </tr><tr> <td><a href="#readlines">readlines</a></td> <td>Read the source code.</td> @@ -348,6 +366,9 @@ <td><a href="#Checker.generate_tokens">generate_tokens</a></td> <td>Tokenize the file, run physical line checks and yield tokens.</td> </tr><tr> +<td><a href="#Checker.init_checker_state">init_checker_state</a></td> +<td>Prepares a custom state for the specific checker plugin.</td> +</tr><tr> <td><a href="#Checker.maybe_check_physical">maybe_check_physical</a></td> <td>If appropriate (based on token), check current physical line(s).</td> </tr><tr> @@ -398,6 +419,11 @@ <b>generate_tokens</b>(<i></i>) <p> Tokenize the file, run physical line checks and yield tokens. +</p><a NAME="Checker.init_checker_state" ID="Checker.init_checker_state"></a> +<h4>Checker.init_checker_state</h4> +<b>init_checker_state</b>(<i>name, argument_names</i>) +<p> + Prepares a custom state for the specific checker plugin. </p><a NAME="Checker.maybe_check_physical" ID="Checker.maybe_check_physical"></a> <h4>Checker.maybe_check_physical</h4> <b>maybe_check_physical</b>(<i>token</i>) @@ -652,6 +678,12 @@ <div align="right"><a href="#top">Up</a></div> <hr /><hr /> +<a NAME="_get_parameters" ID="_get_parameters"></a> +<h2>_get_parameters</h2> +<b>_get_parameters</b>(<i>function</i>) + +<div align="right"><a href="#top">Up</a></div> +<hr /><hr /> <a NAME="_is_eol_token" ID="_is_eol_token"></a> <h2>_is_eol_token</h2> <b>_is_eol_token</b>(<i>token</i>) @@ -660,7 +692,7 @@ <hr /><hr /> <a NAME="_is_eol_token_1" ID="_is_eol_token_1"></a> <h2>_is_eol_token</h2> -<b>_is_eol_token</b>(<i>token</i>) +<b>_is_eol_token</b>(<i>token, _eol_token=_is_eol_token</i>) <div align="right"><a href="#top">Up</a></div> <hr /><hr /> @@ -672,6 +704,21 @@ </p> <div align="right"><a href="#top">Up</a></div> <hr /><hr /> +<a NAME="_parse_multi_options" ID="_parse_multi_options"></a> +<h2>_parse_multi_options</h2> +<b>_parse_multi_options</b>(<i>options, split_token=', '</i>) +<p> +Split and strip and discard empties. +</p><p> + Turns the following: +</p><p> + A, + B, +</p><p> + into ["A", "B"] +</p> +<div align="right"><a href="#top">Up</a></div> +<hr /><hr /> <a NAME="blank_lines" ID="blank_lines"></a> <h2>blank_lines</h2> <b>blank_lines</b>(<i>logical_line, blank_lines, indent_level, line_number, blank_before, previous_logical, previous_indent_level</i>) @@ -697,6 +744,27 @@ </p> <div align="right"><a href="#top">Up</a></div> <hr /><hr /> +<a NAME="break_around_binary_operator" ID="break_around_binary_operator"></a> +<h2>break_around_binary_operator</h2> +<b>break_around_binary_operator</b>(<i>logical_line, tokens</i>) +<p> + Avoid breaks before binary operators. +</p><p> + The preferred place to break around a binary operator is after the + operator, not before it. +</p><p> + W503: (width == 0\n + height == 0) + W503: (width == 0\n and height == 0) +</p><p> + Okay: (width == 0 +\n height == 0) + Okay: foo(\n -x) + Okay: foo(x\n []) + Okay: x = '''\n''' + '' + Okay: foo(x,\n -y) + Okay: foo(x, # comment\n -y) +</p> +<div align="right"><a href="#top">Up</a></div> +<hr /><hr /> <a NAME="comparison_negative" ID="comparison_negative"></a> <h2>comparison_negative</h2> <b>comparison_negative</b>(<i>logical_line</i>) @@ -725,7 +793,9 @@ </p><p> Okay: if arg is not None: E711: if arg != None: + E711: if None == arg: E712: if arg == True: + E712: if False == arg: </p><p> Also, beware of writing if x when you really mean if x is not None -- e.g. when testing whether a variable or argument that defaults to None was @@ -736,7 +806,7 @@ <hr /><hr /> <a NAME="comparison_type" ID="comparison_type"></a> <h2>comparison_type</h2> -<b>comparison_type</b>(<i>logical_line</i>) +<b>comparison_type</b>(<i>logical_line, noqa</i>) <p> Object type comparisons should always use isinstance(). </p><p> @@ -764,6 +834,9 @@ on the same line, never do this for multi-clause statements. Also avoid folding such long lines! </p><p> + Always use a def statement instead of an assignment statement that + binds a lambda expression directly to a name. +</p><p> Okay: if foo == 'blah':\n do_blah_thing() Okay: do_one() Okay: do_two() @@ -777,9 +850,10 @@ E701: try: something() E701: finally: cleanup() E701: if foo == 'blah': one(); two(); three() -</p><p> E702: do_one(); do_two(); do_three() E703: do_four(); # useless semicolon + E704: def f(x): return 2*x + E731: f = lambda x: 2*x </p> <div align="right"><a href="#top">Up</a></div> <hr /><hr /> @@ -851,6 +925,7 @@ Okay: aaa = [123,\n 123] Okay: aaa = ("bbb "\n "ccc") Okay: aaa = "bbb " \\n "ccc" + Okay: aaa = 123 # \\ </p> <div align="right"><a href="#top">Up</a></div> <hr /><hr /> @@ -923,12 +998,15 @@ Okay: a = 1 Okay: if a == 0:\n a = 1 E111: a = 1 + E114: # a = 1 </p><p> Okay: for item in items:\n pass E112: for item in items:\npass + E115: for item in items:\n# Hi\n pass </p><p> Okay: a = 1\nb = 2 E113: a = 1\n b = 2 + E116: a = 1\n # b = 2 </p> <div align="right"><a href="#top">Up</a></div> <hr /><hr /> @@ -942,6 +1020,18 @@ </p> <div align="right"><a href="#top">Up</a></div> <hr /><hr /> +<a NAME="is_binary_operator" ID="is_binary_operator"></a> +<h2>is_binary_operator</h2> +<b>is_binary_operator</b>(<i>token_type, text</i>) + +<div align="right"><a href="#top">Up</a></div> +<hr /><hr /> +<a NAME="is_string_literal" ID="is_string_literal"></a> +<h2>is_string_literal</h2> +<b>is_string_literal</b>(<i>line</i>) + +<div align="right"><a href="#top">Up</a></div> +<hr /><hr /> <a NAME="maximum_line_length" ID="maximum_line_length"></a> <h2>maximum_line_length</h2> <b>maximum_line_length</b>(<i>physical_line, max_line_length, multiline</i>) @@ -1010,6 +1100,27 @@ </p> <div align="right"><a href="#top">Up</a></div> <hr /><hr /> +<a NAME="module_imports_on_top_of_file" ID="module_imports_on_top_of_file"></a> +<h2>module_imports_on_top_of_file</h2> +<b>module_imports_on_top_of_file</b>(<i>logical_line, indent_level, checker_state, noqa</i>) +<p> +Imports are always put at the top of the file, just after any module + comments and docstrings, and before module globals and constants. +</p><p> + Okay: import os + Okay: # this is a comment\nimport os + Okay: '''this is a module docstring'''\nimport os + Okay: r'''this is a module docstring'''\nimport os + Okay: try:\n import x\nexcept:\n pass\nelse:\n pass\nimport y + Okay: try:\n import x\nexcept:\n pass\nfinally:\n pass\nimport y + E402: a=1\nimport os + E402: 'One string'\n"Two string"\nimport os + E402: a=1\nfrom sys import x +</p><p> + Okay: if x:\n import os +</p> +<div align="right"><a href="#top">Up</a></div> +<hr /><hr /> <a NAME="mute_string" ID="mute_string"></a> <h2>mute_string</h2> <b>mute_string</b>(<i>text</i>) @@ -1048,6 +1159,9 @@ <b>process_options</b>(<i>arglist=None, parse_argv=False, config_file=None, parser=None</i>) <p> Process options passed either via arglist or via command line args. +</p><p> + Passing in the ``config_file`` parameter allows other tools, such as flake8 + to specify their own options to be processed in pep8. </p> <div align="right"><a href="#top">Up</a></div> <hr /><hr /> @@ -1103,7 +1217,14 @@ <h2>read_config</h2> <b>read_config</b>(<i>options, args, arglist, parser</i>) <p> -Read both user configuration and local configuration. +Read and parse configurations +</p><p> + If a config file is specified on the command line with the "--config" + option, then only it is used for configuration. +</p><p> + Otherwise, the user configuration (~/.config/pep8) and any local + configurations in the current directory or above will be merged together + (in that order) using the read method of ConfigParser. </p> <div align="right"><a href="#top">Up</a></div> <hr /><hr /> @@ -1237,6 +1358,7 @@ Okay: boolean(a != b) Okay: boolean(a <= b) Okay: boolean(a >= b) + Okay: def foo(arg: int = 42): </p><p> E251: def complex(real, imag = 0.0): E251: return magic(r = real, i = imag) @@ -1277,6 +1399,7 @@ E262: x = x + 1 #Increment x E262: x = x + 1 # Increment x E265: #Block comment + E266: ### Block comment </p> <div align="right"><a href="#top">Up</a></div> <hr /><hr />