| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1815,7 +1815,7 @@ def normalize_kwargs(kw, alias_mapping=None, required=(), forbidden=(), | |||
| 1815 | 1815 | "are in kwargs".format(keys=fail_keys)) | |
| 1816 | 1816 | ||
| 1817 | 1817 | if allowed is not None: | |
| 1818 | - allowed_set = set(required) | set(allowed) | ||
| 1818 | + allowed_set = {*required, *allowed} | ||
| 1819 | 1819 | fail_keys = [k for k in ret if k not in allowed_set] | |
| 1820 | 1820 | if fail_keys: | |
| 1821 | 1821 | raise TypeError( | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -65,16 +65,16 @@ def get_unicode_index(symbol, math=True): | |||
| 65 | 65 | # length, usually longer than a hyphen. | |
| 66 | 66 | if symbol == '-': | |
| 67 | 67 | return 0x2212 | |
| 68 | - try:# This will succeed if symbol is a single unicode char | ||
| 68 | + try: # This will succeed if symbol is a single unicode char | ||
| 69 | 69 | return ord(symbol) | |
| 70 | 70 | except TypeError: | |
| 71 | 71 | pass | |
| 72 | - try:# Is symbol a TeX symbol (i.e. \alpha) | ||
| 72 | + try: # Is symbol a TeX symbol (i.e. \alpha) | ||
| 73 | 73 | return tex2uni[symbol.strip("\\")] | |
| 74 | 74 | except KeyError: | |
| 75 | - message = """'%(symbol)s' is not a valid Unicode character or | ||
| 76 | - TeX/Type1 symbol"""%locals() | ||
| 77 | - raise ValueError(message) | ||
| 75 | + raise ValueError( | ||
| 76 | + "'{}' is not a valid Unicode character or TeX/Type1 symbol" | ||
| 77 | + .format(symbol)) | ||
| 78 | 78 | ||
| 79 | 79 | ||
| 80 | 80 | unichr_safe = cbook.deprecated("3.0")(chr) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -63,7 +63,7 @@ def __call__(self, s): | |||
| 63 | 63 | s = s.lower() | |
| 64 | 64 | if s in self.valid: | |
| 65 | 65 | return self.valid[s] | |
| 66 | - raise ValueError('Unrecognized %s string "%s": valid strings are %s' | ||
| 66 | + raise ValueError('Unrecognized %s string %r: valid strings are %s' | ||
| 67 | 67 | % (self.key, s, list(six.itervalues(self.valid)))) | |
| 68 | 68 | ||
| 69 | 69 | ||
@@ -935,25 +935,13 @@ def _validate_linestyle(ls): | |||
| 935 | 935 | A validator for all possible line styles, the named ones *and* | |
| 936 | 936 | the on-off ink sequences. | |
| 937 | 937 | """ | |
| 938 | - # Look first for a valid named line style, like '--' or 'solid' | ||
| 939 | - if isinstance(ls, six.string_types): | ||
| 940 | - try: | ||
| 941 | - return _validate_named_linestyle(ls) | ||
| 942 | - except (UnicodeDecodeError, KeyError): | ||
| 943 | - # On Python 2, string-like *ls*, like for example | ||
| 944 | - # 'solid'.encode('utf-16'), may raise a unicode error. | ||
| 945 | - raise ValueError("the linestyle string {!r} is not a valid " | ||
| 946 | - "string.".format(ls)) | ||
| 947 | - | ||
| 948 | - if isinstance(ls, (bytes, bytearray)): | ||
| 949 | - # On Python 2, a string-like *ls* should already have lead to a | ||
| 950 | - # successful return or to raising an exception. On Python 3, we have | ||
| 951 | - # to manually raise an exception in the case of a byte-like *ls*. | ||
| 952 | - # Otherwise, if *ls* is of even-length, it will be passed to the | ||
| 953 | - # instance of validate_nseq_float, which will return an absurd on-off | ||
| 954 | - # ink sequence... | ||
| 955 | - raise ValueError("linestyle {!r} neither looks like an on-off ink " | ||
| 956 | - "sequence nor a valid string.".format(ls)) | ||
| 938 | + # Look first for a valid named line style, like '--' or 'solid' Also | ||
| 939 | + # includes bytes(-arrays) here (they all fail _validate_named_linestyle); | ||
| 940 | + # otherwise, if *ls* is of even-length, it will be passed to the instance | ||
| 941 | + # of validate_nseq_float, which will return an absurd on-off ink | ||
| 942 | + # sequence... | ||
| 943 | + if isinstance(ls, (str, bytes, bytearray)): | ||
| 944 | + return _validate_named_linestyle(ls) | ||
| 957 | 945 | ||
| 958 | 946 | # Look for an on-off ink sequence (in points) *of even length*. | |
| 959 | 947 | # Offset is set to None. | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -917,7 +917,7 @@ def on_text_change(self, func): | |||
| 917 | 917 | ||
| 918 | 918 | def on_submit(self, func): | |
| 919 | 919 | """ | |
| 920 | - When the user hits enter or leaves the submision box, call this | ||
| 920 | + When the user hits enter or leaves the submission box, call this | ||
| 921 | 921 | *func* with event. | |
| 922 | 922 | ||
| 923 | 923 | A connection id is returned which can be used to disconnect. | |
@@ -928,8 +928,8 @@ def on_submit(self, func): | |||
| 928 | 928 | return cid | |
| 929 | 929 | ||
| 930 | 930 | def disconnect(self, cid): | |
| 931 | - """remove the observer with connection id *cid*""" | ||
| 932 | - for reg in (self.change_observers, self.submit_observers): | ||
| 931 | + """Remove the observer with connection id *cid*.""" | ||
| 932 | + for reg in [self.change_observers, self.submit_observers]: | ||
| 933 | 933 | try: | |
| 934 | 934 | del reg[cid] | |
| 935 | 935 | except KeyError: | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -284,11 +284,7 @@ def __init__(self): | |||
| 284 | 284 | if sys.platform == 'win32': | |
| 285 | 285 | self.has_pkgconfig = False | |
| 286 | 286 | else: | |
| 287 | - try: | ||
| 288 | - self.pkg_config = os.environ['PKG_CONFIG'] | ||
| 289 | - except KeyError: | ||
| 290 | - self.pkg_config = 'pkg-config' | ||
| 291 | - | ||
| 287 | + self.pkg_config = os.environ.get('PKG_CONFIG', 'pkg-config') | ||
| 292 | 288 | self.set_pkgconfig_path() | |
| 293 | 289 | self.has_pkgconfig = shutil.which(self.pkg_config) is not None | |
| 294 | 290 | if not self.has_pkgconfig: | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,17 +1,12 @@ | |||
| 1 | 1 | """Functions for Github API requests.""" | |
| 2 | 2 | ||
| 3 | - try: | ||
| 4 | - input = raw_input | ||
| 5 | - except NameError: | ||
| 6 | - pass | ||
| 7 | - | ||
| 3 | + import getpass | ||
| 4 | + import json | ||
| 8 | 5 | import os | |
| 9 | 6 | import re | |
| 10 | 7 | import sys | |
| 11 | 8 | ||
| 12 | 9 | import requests | |
| 13 | - import getpass | ||
| 14 | - import json | ||
| 15 | 10 | ||
| 16 | 11 | try: | |
| 17 | 12 | import requests_cache | |
| Back | FazBrowse Home | New Git URL |
0 commit comments