-
Notifications
You must be signed in to change notification settings - Fork 0
Sourcery refactored develop branch #1
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
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -116,7 +116,7 @@ def _getBuiltinNames(): | |
|
|
||
|
|
||
| builtin_names, builtin_warnings = _getBuiltinNames() | ||
| builtin_named_values = dict((getattr(builtins, x), x) for x in builtin_names) | ||
| builtin_named_values = {getattr(builtins, x): x for x in builtin_names} | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Lines
|
||
| builtin_named_values_list = tuple(builtin_named_values) | ||
|
|
||
| assert "__import__" in builtin_names | ||
|
|
@@ -129,11 +129,12 @@ def _getBuiltinNames(): | |
|
|
||
|
|
||
| def getBuiltinTypeNames(): | ||
| result = [] | ||
| result = [ | ||
| builtin_name | ||
| for builtin_name in builtin_names | ||
| if isinstance(getattr(builtins, builtin_name), type) | ||
| ] | ||
|
|
||
| for builtin_name in builtin_names: | ||
| if isinstance(getattr(builtins, builtin_name), type): | ||
| result.append(builtin_name) | ||
|
Comment on lines
-132
to
-136
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
|
|
||
| return tuple(sorted(result)) | ||
|
|
||
|
|
@@ -188,7 +189,7 @@ def _getAnonBuiltins(): | |
|
|
||
|
|
||
| builtin_anon_names, builtin_anon_codes = _getAnonBuiltins() | ||
| builtin_anon_values = dict((b, a) for a, b in builtin_anon_names.items()) | ||
| builtin_anon_values = {b: a for a, b in builtin_anon_names.items()} | ||
|
Comment on lines
-191
to
+192
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Lines
|
||
|
|
||
| # For being able to check if it's not hashable, we need something not using | ||
| # a hash. | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -69,11 +69,7 @@ def compareConstants(a, b): | |
| if len(a) != len(b): | ||
| return False | ||
|
|
||
| for ea, eb in zip(a, b): | ||
| if not compareConstants(ea, eb): | ||
| return False | ||
| return True | ||
|
|
||
| return all(compareConstants(ea, eb) for ea, eb in zip(a, b)) | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
| if type(a) is dict: | ||
| if len(a) != len(b): | ||
| return False | ||
|
|
@@ -150,19 +146,14 @@ def isConstant(constant): | |
| return False | ||
| return True | ||
| elif constant_type in (tuple, list): | ||
| for element_value in constant: | ||
| if not isConstant(element_value): | ||
| return False | ||
| return True | ||
| return all(isConstant(element_value) for element_value in constant) | ||
| elif constant_type is slice: | ||
| if ( | ||
| not isConstant(constant.start) | ||
| or not isConstant(constant.stop) | ||
| or not isConstant(constant.step) | ||
| ): | ||
| return False | ||
| return bool( | ||
| isConstant(constant.start) | ||
| and isConstant(constant.stop) | ||
| and isConstant(constant.step) | ||
| ) | ||
|
|
||
| return True | ||
|
Comment on lines
-153
to
-165
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
| elif constant_type in ( | ||
| str, | ||
| unicode, | ||
|
|
@@ -230,15 +221,9 @@ def isMutable(constant): | |
| elif constant_type in (dict, list, set, bytearray): | ||
| return True | ||
| elif constant_type is tuple: | ||
| for value in constant: | ||
| if isMutable(value): | ||
| return True | ||
| return False | ||
| return any(isMutable(value) for value in constant) | ||
| elif constant_type is frozenset: | ||
| for value in constant: | ||
| if isMutable(value): | ||
| return True | ||
| return False | ||
| return any(isMutable(value) for value in constant) | ||
|
Comment on lines
-233
to
+226
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
| elif constant is Ellipsis: | ||
| return False | ||
| elif constant is NotImplemented: | ||
|
|
@@ -277,15 +262,9 @@ def isHashable(constant): | |
| elif constant_type in (dict, list, set, slice, bytearray): | ||
| return False | ||
| elif constant_type is tuple: | ||
| for value in constant: | ||
| if not isHashable(value): | ||
| return False | ||
| return True | ||
| return not any(not isHashable(value) for value in constant) | ||
| elif constant_type is frozenset: | ||
| for value in constant: | ||
| if not isHashable(value): | ||
| return False | ||
| return True | ||
| return all(isHashable(value) for value in constant) | ||
|
Comment on lines
-280
to
+267
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
| elif constant is Ellipsis: | ||
| return True | ||
| else: | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -53,11 +53,7 @@ def getRootModules(): | |
|
|
||
|
|
||
| def hasRootModule(module_name): | ||
| for module in root_modules: | ||
| if module.getFullName() == module_name: | ||
| return True | ||
|
|
||
| return False | ||
| return any(module.getFullName() == module_name for module in root_modules) | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
|
|
||
|
|
||
| def replaceRootModule(old, new): | ||
|
|
@@ -112,12 +108,11 @@ def _normalizeModuleFilename(filename): | |
|
|
||
| def getUncompiledModule(module_name, module_filename): | ||
| for uncompiled_module in uncompiled_modules: | ||
| if module_name == uncompiled_module.getFullName(): | ||
| if areSamePaths( | ||
| _normalizeModuleFilename(module_filename), | ||
| _normalizeModuleFilename(uncompiled_module.filename), | ||
| ): | ||
| return uncompiled_module | ||
| if module_name == uncompiled_module.getFullName() and areSamePaths( | ||
| _normalizeModuleFilename(module_filename), | ||
| _normalizeModuleFilename(uncompiled_module.filename), | ||
| ): | ||
| return uncompiled_module | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
|
|
||
| return None | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -226,45 +226,39 @@ def _splitShellPattern(value): | |
| def getShallFollowInNoCase(): | ||
| """ *list*, items of "--nofollow-import-to=" / "--recurse-not-to=" | ||
| """ | ||
| return sum([_splitShellPattern(x) for x in options.recurse_not_modules], []) | ||
| return sum((_splitShellPattern(x) for x in options.recurse_not_modules), []) | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
|
|
||
|
|
||
| def getShallFollowModules(): | ||
| """ *list*, items of "--follow-import-to=" / "--recurse-to=" | ||
| """ | ||
| return sum( | ||
| [ | ||
| _splitShellPattern(x) | ||
| for x in options.recurse_modules | ||
| + options.include_modules | ||
| + options.include_packages | ||
| ], | ||
| [], | ||
| ) | ||
| return sum((_splitShellPattern(x) for x in options.recurse_modules | ||
| + options.include_modules | ||
| + options.include_packages), []) | ||
|
Comment on lines
-235
to
+237
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
|
|
||
|
|
||
| def getShallFollowExtra(): | ||
| """ *list*, items of "--include-plugin-directory=" | ||
| """ | ||
| return sum([_splitShellPattern(x) for x in options.recurse_extra], []) | ||
| return sum((_splitShellPattern(x) for x in options.recurse_extra), []) | ||
|
Comment on lines
-249
to
+243
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
|
|
||
|
|
||
| def getShallFollowExtraFilePatterns(): | ||
| """ *list*, items of "--include-plugin-files=" | ||
| """ | ||
| return sum([_splitShellPattern(x) for x in options.recurse_extra_files], []) | ||
| return sum((_splitShellPattern(x) for x in options.recurse_extra_files), []) | ||
|
Comment on lines
-255
to
+249
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
|
|
||
|
|
||
| def getMustIncludeModules(): | ||
| """ *list*, items of "--include-module=" | ||
| """ | ||
| return sum([_splitShellPattern(x) for x in options.include_modules], []) | ||
| return sum((_splitShellPattern(x) for x in options.include_modules), []) | ||
|
Comment on lines
-261
to
+255
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
|
|
||
|
|
||
| def getMustIncludePackages(): | ||
| """ *list*, items of "--include-package=" | ||
| """ | ||
| return sum([_splitShellPattern(x) for x in options.include_packages], []) | ||
| return sum((_splitShellPattern(x) for x in options.include_packages), []) | ||
|
Comment on lines
-267
to
+261
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
|
|
||
|
|
||
| def shallWarnImplicitRaises(): | ||
|
|
@@ -372,7 +366,7 @@ def shallUseStaticLibPython(): | |
| return ( | ||
| os.path.exists(os.path.join(sys.prefix, "conda-meta")) | ||
| and not Utils.isWin32Windows() | ||
| and not Utils.getOS() == "Darwin" | ||
| and Utils.getOS() != "Darwin" | ||
|
Comment on lines
-375
to
+369
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
| ) | ||
|
|
||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -127,10 +127,7 @@ def needsSetLiteralReverseInsertion(): | |
|
|
||
|
|
||
| def needsDuplicateArgumentColOffset(): | ||
| if python_version < 353: | ||
| return False | ||
| else: | ||
| return True | ||
| return python_version >= 353 | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
|
|
||
|
|
||
| def isUninstalledPython(): | ||
|
|
@@ -246,9 +243,10 @@ def getPythonABI(): | |
| # Cyclic dependency here. | ||
| from nuitka.Options import isPythonDebug | ||
|
|
||
| if isPythonDebug() or hasattr(sys, "getobjects"): | ||
| if not abiflags.startswith("d"): | ||
| abiflags = "d" + abiflags | ||
| if ( | ||
| isPythonDebug() or hasattr(sys, "getobjects") | ||
| ) and not abiflags.startswith("d"): | ||
| abiflags = "d" + abiflags | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
| else: | ||
| abiflags = "" | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -109,9 +109,7 @@ def atInternal(self): | |
| it is already internal. | ||
| """ | ||
| if not self.isInternal(): | ||
| result = self._clone(self.line) | ||
|
|
||
| return result | ||
| return self._clone(self.line) | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
| else: | ||
| return self | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -121,12 +121,13 @@ def addVariableUser(self, user): | |
|
|
||
| # These are not really scopes, just shared uses. | ||
| if ( | ||
| user.isExpressionGeneratorObjectBody() | ||
| or user.isExpressionCoroutineObjectBody() | ||
| or user.isExpressionAsyncgenObjectBody() | ||
| ): | ||
| if self.owner is user.getParentVariableProvider(): | ||
| return | ||
| ( | ||
| user.isExpressionGeneratorObjectBody() | ||
| or user.isExpressionCoroutineObjectBody() | ||
| or user.isExpressionAsyncgenObjectBody() | ||
| ) | ||
| ) and self.owner is user.getParentVariableProvider(): | ||
| return | ||
|
Comment on lines
-124
to
+130
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
|
|
||
| self.shared_scopes = True | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -69,14 +69,12 @@ def iterItems(d): | |
| from urllib import ( # pylint: disable=I0021,import-error,no-name-in-module | ||
| urlretrieve, | ||
| ) | ||
| from cStringIO import StringIO # pylint: disable=I0021,import-error | ||
| else: | ||
| from urllib.request import ( # pylint: disable=I0021,import-error,no-name-in-module | ||
| urlretrieve, | ||
| ) | ||
|
|
||
| if str is bytes: | ||
| from cStringIO import StringIO # pylint: disable=I0021,import-error | ||
| else: | ||
|
Comment on lines
+72
to
-79
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Lines
|
||
| from io import StringIO # pylint: disable=I0021,import-error | ||
|
|
||
| try: | ||
|
|
@@ -85,7 +83,7 @@ def iterItems(d): | |
| # Lame replacement for functools.total_ordering, which does not exist on | ||
| # Python2.6, this requires "<" and "=" and adds all other operations. | ||
| def total_ordering(cls): | ||
| cls.__ne__ = lambda self, other: not self == other | ||
| cls.__ne__ = lambda self, other: self != other | ||
|
Comment on lines
-88
to
+86
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
| cls.__le__ = lambda self, other: self == other or self < other | ||
| cls.__gt__ = lambda self, other: self != other and not self < other | ||
| cls.__ge__ = lambda self, other: self == other and not self < other | ||
|
|
@@ -98,15 +96,13 @@ def total_ordering(cls): | |
| Iterable, | ||
| MutableSet, | ||
| ) | ||
| intern = intern # pylint: disable=I0021,undefined-variable | ||
| else: | ||
| from collections.abc import ( # pylint: disable=I0021,import-error,no-name-in-module | ||
| Iterable, # pylint: disable=I0021,import-error | ||
| MutableSet, # pylint: disable=I0021,import-error | ||
| ) | ||
|
|
||
| if str is bytes: | ||
| intern = intern # pylint: disable=I0021,undefined-variable | ||
| else: | ||
|
Comment on lines
+99
to
-109
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Lines
|
||
| intern = sys.intern | ||
|
|
||
|
|
||
|
|
@@ -118,9 +114,7 @@ def getMetaClassBase(meta_class_prefix): | |
| class MetaClass(ABCMeta): | ||
| pass | ||
|
|
||
| MetaClassBase = MetaClass("%sMetaClassBase" % meta_class_prefix, (object,), {}) | ||
|
|
||
| return MetaClassBase | ||
| return MetaClass("%sMetaClassBase" % meta_class_prefix, (object,), {}) | ||
|
Comment on lines
-121
to
+117
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
|
|
||
|
|
||
| # For PyLint to be happy. | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -174,9 +174,12 @@ def _setupSconsEnvironment(): | |
| """ | ||
|
|
||
| # For Python2, avoid unicode working directory. | ||
| if Utils.isWin32Windows() and python_version < 300: | ||
| if os.getcwd() != os.getcwdu(): | ||
| os.chdir(getWindowsShortPathName(os.getcwdu())) | ||
| if ( | ||
| Utils.isWin32Windows() | ||
| and python_version < 300 | ||
| and os.getcwd() != os.getcwdu() | ||
| ): | ||
| os.chdir(getWindowsShortPathName(os.getcwdu())) | ||
|
Comment on lines
-177
to
+182
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
|
|
||
| if Utils.isWin32Windows(): | ||
| # On Win32, we use the Python.DLL path for some things. We pass it | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -128,7 +128,11 @@ def site_data_dir(appname=None, appauthor=None, version=None, multipath=False): | |
|
|
||
| WARNING: Do not use this on Windows. See the Vista-Fail note above for why. | ||
| """ | ||
| if system == "win32": | ||
| if system == 'darwin': | ||
| path = os.path.expanduser('/Library/Application Support') | ||
| if appname: | ||
| path = os.path.join(path, appname) | ||
| elif system == "win32": | ||
|
Comment on lines
-131
to
+135
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
| if appauthor is None: | ||
| appauthor = appname | ||
| path = os.path.normpath(_get_win_folder("CSIDL_COMMON_APPDATA")) | ||
|
|
@@ -137,10 +141,6 @@ def site_data_dir(appname=None, appauthor=None, version=None, multipath=False): | |
| path = os.path.join(path, appauthor, appname) | ||
| else: | ||
| path = os.path.join(path, appname) | ||
| elif system == 'darwin': | ||
| path = os.path.expanduser('/Library/Application Support') | ||
| if appname: | ||
| path = os.path.join(path, appname) | ||
| else: | ||
| # XDG default for $XDG_DATA_DIRS | ||
| # only first, if multipath is False | ||
|
|
@@ -152,10 +152,7 @@ def site_data_dir(appname=None, appauthor=None, version=None, multipath=False): | |
| appname = os.path.join(appname, version) | ||
| pathlist = [os.sep.join([x, appname]) for x in pathlist] | ||
|
|
||
| if multipath: | ||
| path = os.pathsep.join(pathlist) | ||
| else: | ||
| path = pathlist[0] | ||
| path = os.pathsep.join(pathlist) if multipath else pathlist[0] | ||
| return path | ||
|
|
||
| if appname and version: | ||
|
|
@@ -247,10 +244,7 @@ def site_config_dir(appname=None, appauthor=None, version=None, multipath=False) | |
| appname = os.path.join(appname, version) | ||
| pathlist = [os.sep.join([x, appname]) for x in pathlist] | ||
|
|
||
| if multipath: | ||
| path = os.pathsep.join(pathlist) | ||
| else: | ||
| path = pathlist[0] | ||
| path = os.pathsep.join(pathlist) if multipath else pathlist[0] | ||
|
Comment on lines
-250
to
+247
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
| return path | ||
|
|
||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function
_normalizePathrefactored with the following changes:merge-nested-ifs)