summaryrefslogtreecommitdiff
path: root/docs/source/plugin-development/cross-compatibility.rst
diff options
context:
space:
mode:
authorIan Cordasco <graffatcolmingov@gmail.com>2016-06-26 06:41:47 -0500
committerIan Cordasco <graffatcolmingov@gmail.com>2016-06-26 06:41:47 -0500
commit5a9b7c27abdd99b05a04e3f7c6121f5fc7fb5ce3 (patch)
tree97193f1c1cd599828ead11f73ee7b357281aff38 /docs/source/plugin-development/cross-compatibility.rst
parent6b7855e102a09027a8b2898272f5b86edbc0d10d (diff)
downloadflake8-5a9b7c27abdd99b05a04e3f7c6121f5fc7fb5ce3.tar.gz
Update compatibility docs
Diffstat (limited to 'docs/source/plugin-development/cross-compatibility.rst')
-rw-r--r--docs/source/plugin-development/cross-compatibility.rst10
1 files changed, 8 insertions, 2 deletions
diff --git a/docs/source/plugin-development/cross-compatibility.rst b/docs/source/plugin-development/cross-compatibility.rst
index 1aa45e3..ed8762f 100644
--- a/docs/source/plugin-development/cross-compatibility.rst
+++ b/docs/source/plugin-development/cross-compatibility.rst
@@ -106,6 +106,8 @@ options with |Flake8| and have it work on |Flake8| 2.x and 3.x.
.. code-block:: python
+ import optparse
+
option_args = ('-X', '--example-flag')
option_kwargs = {
'type': 'string',
@@ -115,7 +117,7 @@ options with |Flake8| and have it work on |Flake8| 2.x and 3.x.
try:
# Flake8 3.x registration
parser.add_option(*option_args, **option_kwargs)
- except TypeError:
+ except (optparse.OptionError, TypeError):
# Flake8 2.x registration
parse_from_config = option_kwargs.pop('parse_from_config', False)
parser.add_option(*option_args, **option_kwargs)
@@ -127,13 +129,17 @@ Or, you can write a tiny helper function:
.. code-block:: python
+ import optparse
+
def register_opt(parser, *args, **kwargs):
try:
# Flake8 3.x registration
parser.add_option(*args, **kwargs)
- except TypeError:
+ except (optparse.OptionError, TypeError):
# Flake8 2.x registration
parse_from_config = kwargs.pop('parse_from_config', False)
+ kwargs.pop('comma_separated_list', False)
+ kwargs.pop('normalize_paths', False)
parser.add_option(*args, **kwargs)
if parse_from_config:
parser.config_options.append(args[-1].lstrip('-'))