"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "client/configuration.py" between
pyre-check-0.0.51.tar.gz and pyre-check-0.0.52.tar.gz

About: Pyre is a performant type checker for Python (ships with Pysa, a security focused static analysis tool).

configuration.py  (pyre-check-0.0.51):configuration.py  (pyre-check-0.0.52)
skipping to change at line 42 skipping to change at line 42
class InvalidConfiguration(Exception): class InvalidConfiguration(Exception):
pass pass
class SearchPathElement: class SearchPathElement:
def __init__(self, root: str, subdirectory: Optional[str] = None) -> None: def __init__(self, root: str, subdirectory: Optional[str] = None) -> None:
self.root = os.path.expanduser(root) self.root = os.path.expanduser(root)
self.subdirectory = subdirectory self.subdirectory = subdirectory
@staticmethod @staticmethod
def expand( def expand(path: Union[Dict[str, str], str]) -> "SearchPathElement":
path: Union[Dict[str, str], str], base: Optional[str] = None
) -> "SearchPathElement":
if isinstance(path, str): if isinstance(path, str):
if base:
path = expand_relative_path(base, path)
return SearchPathElement(path) return SearchPathElement(path)
else: else:
if "root" in path and "subdirectory" in path: if "root" in path and "subdirectory" in path:
root = path["root"] root = path["root"]
subdirectory = path["subdirectory"] subdirectory = path["subdirectory"]
if base:
root = expand_relative_path(base, root)
return SearchPathElement(root, subdirectory) return SearchPathElement(root, subdirectory)
elif "site-package" in path: elif "site-package" in path:
site_root = site.getsitepackages() site_root = site.getsitepackages()
subdirectory = path["site-package"] subdirectory = path["site-package"]
found_element = None found_element = None
for root in site_root: for root in site_root:
site_package_element = SearchPathElement(root, subdirectory) site_package_element = SearchPathElement(root, subdirectory)
if os.path.isdir(site_package_element.path()): if os.path.isdir(site_package_element.path()):
found_element = site_package_element found_element = site_package_element
skipping to change at line 482 skipping to change at line 476
raise EnvironmentException( raise EnvironmentException(
"Local configuration `{}` does not specify any sources to type c heck.".format( "Local configuration `{}` does not specify any sources to type c heck.".format(
local_configuration local_configuration
) )
) )
def _read(self, path: str) -> None: def _read(self, path: str) -> None:
try: try:
with open(path) as file: with open(path) as file:
LOG.debug("Reading configuration `%s`...", path) LOG.debug("Reading configuration `%s`...", path)
configuration_directory = os.path.dirname(os.path.realpath(path) )
configuration = _ConfigurationFile(file) configuration = _ConfigurationFile(file)
source_directories = configuration.consume( source_directories = configuration.consume(
"source_directories", "source_directories",
default=[], default=[],
current=self.source_directories, current=self.source_directories,
print_on_success=True, print_on_success=True,
raise_on_override=True, raise_on_override=True,
) )
self.source_directories = [ configuration_directory = os.path.dirname(path)
expand_relative_path(configuration_directory, directory) if configuration_directory:
for directory in source_directories self.source_directories = [
] os.path.join(configuration_directory, directory)
for directory in source_directories
]
else:
self.source_directories = [
os.path.expanduser(directory)
for directory in source_directories
]
self.targets = configuration.consume( self.targets = configuration.consume(
"targets", "targets",
default=[], default=[],
current=self.targets, current=self.targets,
print_on_success=True, print_on_success=True,
raise_on_override=True, raise_on_override=True,
) )
if configuration.consume("disabled", default=False): if configuration.consume("disabled", default=False):
self.disabled = True self.disabled = True
logger = configuration.consume("logger", current=self.logger) self.logger = configuration.consume("logger", current=self.logge
if logger: r)
self.logger = expand_relative_path(configuration_directory,
logger)
self.formatter = configuration.consume( self.formatter = configuration.consume(
"formatter", current=self.formatter "formatter", current=self.formatter
) )
self.strict = configuration.consume("strict", default=self.stric t) self.strict = configuration.consume("strict", default=self.stric t)
ignore_all_errors = configuration.consume( ignore_all_errors = configuration.consume(
"ignore_all_errors", default=[] "ignore_all_errors", default=[]
) )
configuration_path = os.path.dirname(os.path.realpath(path))
self.ignore_all_errors.extend( self.ignore_all_errors.extend(
[ [
expand_relative_path(root=configuration_directory, path= path) expand_relative_path(root=configuration_path, path=path)
for path in ignore_all_errors for path in ignore_all_errors
] ]
) )
ignore_infer = configuration.consume("ignore_infer", default=[]) ignore_infer = configuration.consume("ignore_infer", default=[])
self.ignore_infer.extend( self.ignore_infer.extend(
[ [
expand_relative_path(root=configuration_directory, path= path) expand_relative_path(root=configuration_path, path=path)
for path in ignore_infer for path in ignore_infer
] ]
) )
self.number_of_workers = int( self.number_of_workers = int(
configuration.consume( configuration.consume(
"workers", default=0, current=self.number_of_workers "workers", default=0, current=self.number_of_workers
) )
) )
binary = configuration.consume("binary", current=self._binary) binary = configuration.consume("binary", current=self._binary)
assert binary is None or isinstance(binary, str) assert binary is None or isinstance(binary, str)
if binary is not None: if binary is not None:
binary = expand_relative_path(configuration_directory, binar y) binary = expand_relative_path(configuration_path, binary)
self._binary = binary self._binary = binary
buck_builder_binary = configuration.consume( buck_builder_binary = configuration.consume(
"buck_builder_binary", current=self._buck_builder_binary "buck_builder_binary", current=self._buck_builder_binary
) )
if buck_builder_binary is not None: if buck_builder_binary is not None:
self._buck_builder_binary = expand_relative_path( self._buck_builder_binary = expand_relative_path(
root=configuration_directory, path=buck_builder_binary root=configuration_path, path=buck_builder_binary
) )
additional_search_path = configuration.consume( additional_search_path = configuration.consume(
"search_path", default=[] "search_path", default=[]
) )
if isinstance(additional_search_path, list): if isinstance(additional_search_path, list):
self._search_path.extend( self._search_path.extend(
[ [
SearchPathElement.expand(path, base=configuration_di rectory) SearchPathElement.expand(path)
for path in additional_search_path for path in additional_search_path
] ]
) )
else: else:
self._search_path.append( self._search_path.append(SearchPathElement(additional_search
SearchPathElement( _path))
expand_relative_path(
configuration_directory, additional_search_path
)
)
)
version_hash = configuration.consume( version_hash = configuration.consume(
"version", current=self._version_hash "version", current=self._version_hash
) )
assert version_hash is None or isinstance(version_hash, str) assert version_hash is None or isinstance(version_hash, str)
self._version_hash = version_hash self._version_hash = version_hash
typeshed = configuration.consume("typeshed", current=self._types hed) typeshed = configuration.consume("typeshed", current=self._types hed)
assert typeshed is None or isinstance(typeshed, str) assert typeshed is None or isinstance(typeshed, str)
if typeshed is not None: if typeshed is not None:
typeshed = expand_relative_path(configuration_directory, typ eshed) typeshed = expand_relative_path(configuration_path, typeshed )
self._typeshed = typeshed self._typeshed = typeshed
taint_models_path = configuration.consume("taint_models_path") taint_models_path = configuration.consume("taint_models_path")
assert ( assert (
taint_models_path is None taint_models_path is None
or isinstance(taint_models_path, str) or isinstance(taint_models_path, str)
or isinstance(taint_models_path, list) or isinstance(taint_models_path, list)
) )
configuration_directory = os.path.dirname(os.path.realpath(path) )
if isinstance(taint_models_path, str): if isinstance(taint_models_path, str):
self.taint_models_path.append( self.taint_models_path.append(
expand_relative_path(configuration_directory, taint_mode ls_path) os.path.join(configuration_directory, taint_models_path)
) )
elif isinstance(taint_models_path, list): elif isinstance(taint_models_path, list):
self.taint_models_path.extend( self.taint_models_path.extend(
[ [
expand_relative_path(configuration_directory, path) os.path.join(configuration_directory, path)
for path in taint_models_path for path in taint_models_path
] ]
) )
excludes = configuration.consume("exclude", default=[]) excludes = configuration.consume("exclude", default=[])
if isinstance(excludes, list): if isinstance(excludes, list):
self.excludes.extend( self.excludes.extend(excludes)
[
expand_relative_path(configuration_directory, path)
for path in excludes
]
)
else: else:
self.excludes.append( self.excludes.append(excludes)
expand_relative_path(configuration_directory, excludes)
)
extensions = configuration.consume("extensions", default=[]) extensions = configuration.consume("extensions", default=[])
self.extensions.extend(extensions) self.extensions.extend(extensions)
# We rely on the configuration SHA1 to make # We rely on the configuration SHA1 to make
if configuration.consume("saved_state"): if configuration.consume("saved_state"):
self.file_hash = configuration.file_hash self.file_hash = configuration.file_hash
use_buck_builder = configuration.consume("use_buck_builder") use_buck_builder = configuration.consume("use_buck_builder")
if self._use_buck_builder is None: if self._use_buck_builder is None:
self._use_buck_builder = use_buck_builder self._use_buck_builder = use_buck_builder
self.autocomplete = configuration.consume("autocomplete", defaul t=False) self.autocomplete = configuration.consume("autocomplete", defaul t=False)
critical_files = configuration.consume("critical_files", default self.other_critical_files = configuration.consume(
=[]) "critical_files", default=[]
self.other_critical_files = [ )
expand_relative_path(root=configuration_directory, path=path
)
for path in critical_files
]
# Warn on deprecated fields. # Warn on deprecated fields.
for deprecated_field in configuration._deprecated.keys(): for deprecated_field in configuration._deprecated.keys():
configuration.consume(deprecated_field) configuration.consume(deprecated_field)
# This block should be at the bottom to be effective. # This block should be at the bottom to be effective.
unused_keys = configuration.unused_keys() unused_keys = configuration.unused_keys()
if unused_keys: if unused_keys:
LOG.warning( LOG.warning(
"Some configuration items were not recognized in " "Some configuration items were not recognized in "
 End of changes. 22 change blocks. 
49 lines changed or deleted 32 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)