From b0335039ca0d1c5993a3e201af71ac9a4c187f7e Mon Sep 17 00:00:00 2001 From: John Reese Date: Wed, 14 Oct 2020 20:19:13 -0700 Subject: [PATCH] apply black 20.8b1 formatting update Summary: allow-large-files black_any_style Reviewed By: zertosh Differential Revision: D24325133 fbshipit-source-id: b4afe80d1e8b2bc993f4b8e3822c02964df47462 --- build/fbcode_builder/getdeps.py | 4 +- build/fbcode_builder/getdeps/builder.py | 10 ++-- build/fbcode_builder/getdeps/buildopts.py | 24 +++++----- build/fbcode_builder/getdeps/cache.py | 16 +++---- build/fbcode_builder/getdeps/copytree.py | 6 +-- build/fbcode_builder/getdeps/envfuncs.py | 12 ++--- build/fbcode_builder/getdeps/errors.py | 4 +- build/fbcode_builder/getdeps/expr.py | 2 +- build/fbcode_builder/getdeps/fetcher.py | 56 +++++++++++------------ build/fbcode_builder/getdeps/load.py | 14 +++--- build/fbcode_builder/getdeps/manifest.py | 16 +++---- build/fbcode_builder/getdeps/platform.py | 4 +- 12 files changed, 84 insertions(+), 84 deletions(-) diff --git a/build/fbcode_builder/getdeps.py b/build/fbcode_builder/getdeps.py index 4f25ed3c8..87f3e2f7f 100755 --- a/build/fbcode_builder/getdeps.py +++ b/build/fbcode_builder/getdeps.py @@ -207,8 +207,8 @@ class ProjectCmdBase(SubCmd): class CachedProject(object): - """ A helper that allows calling the cache logic for a project - from both the build and the fetch code """ + """A helper that allows calling the cache logic for a project + from both the build and the fetch code""" def __init__(self, cache, loader, m): self.m = m diff --git a/build/fbcode_builder/getdeps/builder.py b/build/fbcode_builder/getdeps/builder.py index 3095d6439..e774eac9e 100644 --- a/build/fbcode_builder/getdeps/builder.py +++ b/build/fbcode_builder/getdeps/builder.py @@ -103,17 +103,17 @@ class BuilderBase(object): def run_tests( self, install_dirs, schedule_type, owner, test_filter, retry, no_testpilot ): - """ Execute any tests that we know how to run. If they fail, - raise an exception. """ + """Execute any tests that we know how to run. If they fail, + raise an exception.""" pass def _build(self, install_dirs, reconfigure): - """ Perform the build. + """Perform the build. install_dirs contains the list of installation directories for the dependencies of this project. reconfigure will be set to true if the fetcher determined that the sources have changed in such a way that the build - system needs to regenerate its rules. """ + system needs to regenerate its rules.""" pass def _compute_env(self, install_dirs): @@ -575,7 +575,7 @@ if __name__ == "__main__": use_cmd_prefix = False def get_property(test, propname, defval=None): - """ extracts a named property from a cmake test info json blob. + """extracts a named property from a cmake test info json blob. The properties look like: [{"name": "WORKING_DIRECTORY"}, {"value": "something"}] diff --git a/build/fbcode_builder/getdeps/buildopts.py b/build/fbcode_builder/getdeps/buildopts.py index 56de827a6..bdb90e396 100644 --- a/build/fbcode_builder/getdeps/buildopts.py +++ b/build/fbcode_builder/getdeps/buildopts.py @@ -56,18 +56,18 @@ class BuildOptions(object): vcvars_path=None, allow_system_packages=False, ): - """ fbcode_builder_dir - the path to either the in-fbsource fbcode_builder dir, - or for shipit-transformed repos, the build dir that - has been mapped into that dir. - scratch_dir - a place where we can store repos and build bits. - This path should be stable across runs and ideally - should not be in the repo of the project being built, - but that is ultimately where we generally fall back - for builds outside of FB - install_dir - where the project will ultimately be installed - num_jobs - the level of concurrency to use while building - use_shipit - use real shipit instead of the simple shipit transformer - vcvars_path - Path to external VS toolchain's vsvarsall.bat + """fbcode_builder_dir - the path to either the in-fbsource fbcode_builder dir, + or for shipit-transformed repos, the build dir that + has been mapped into that dir. + scratch_dir - a place where we can store repos and build bits. + This path should be stable across runs and ideally + should not be in the repo of the project being built, + but that is ultimately where we generally fall back + for builds outside of FB + install_dir - where the project will ultimately be installed + num_jobs - the level of concurrency to use while building + use_shipit - use real shipit instead of the simple shipit transformer + vcvars_path - Path to external VS toolchain's vsvarsall.bat """ if not num_jobs: import multiprocessing diff --git a/build/fbcode_builder/getdeps/cache.py b/build/fbcode_builder/getdeps/cache.py index 5bbcdfc2a..a261541c7 100644 --- a/build/fbcode_builder/getdeps/cache.py +++ b/build/fbcode_builder/getdeps/cache.py @@ -7,33 +7,33 @@ from __future__ import absolute_import, division, print_function, unicode_litera class ArtifactCache(object): - """ The ArtifactCache is a small abstraction that allows caching + """The ArtifactCache is a small abstraction that allows caching named things in some external storage mechanism. The primary use case is for storing the build products on CI - systems to accelerate the build """ + systems to accelerate the build""" def download_to_file(self, name, dest_file_name): - """ If `name` exists in the cache, download it and place it + """If `name` exists in the cache, download it and place it in the specified `dest_file_name` location on the filesystem. If a transient issue was encountered a TransientFailure shall be raised. If `name` doesn't exist in the cache `False` shall be returned. If `dest_file_name` was successfully updated `True` shall be returned. - All other conditions shall raise an appropriate exception. """ + All other conditions shall raise an appropriate exception.""" return False def upload_from_file(self, name, source_file_name): - """ Causes `name` to be populated in the cache by uploading + """Causes `name` to be populated in the cache by uploading the contents of `source_file_name` to the storage system. If a transient issue was encountered a TransientFailure shall be raised. If the upload failed for some other reason, an appropriate - exception shall be raised. """ + exception shall be raised.""" pass def create_cache(): - """ This function is monkey patchable to provide an actual - implementation """ + """This function is monkey patchable to provide an actual + implementation""" return None diff --git a/build/fbcode_builder/getdeps/copytree.py b/build/fbcode_builder/getdeps/copytree.py index 27cff565d..37d17fb9c 100644 --- a/build/fbcode_builder/getdeps/copytree.py +++ b/build/fbcode_builder/getdeps/copytree.py @@ -48,11 +48,11 @@ def find_eden_root(dirpath): def prefetch_dir_if_eden(dirpath): - """ After an amend/rebase, Eden may need to fetch a large number + """After an amend/rebase, Eden may need to fetch a large number of trees from the servers. The simplistic single threaded walk performed by copytree makes this more expensive than is desirable so we help accelerate things by performing a prefetch on the - source directory """ + source directory""" global PREFETCHED_DIRS if dirpath in PREFETCHED_DIRS: return @@ -68,7 +68,7 @@ def prefetch_dir_if_eden(dirpath): def copytree(src_dir, dest_dir, ignore=None): - """ Recursively copy the src_dir to the dest_dir, filtering + """Recursively copy the src_dir to the dest_dir, filtering out entries using the ignore lambda. The behavior of the ignore lambda must match that described by `shutil.copytree`. This `copytree` function knows how to prefetch data when diff --git a/build/fbcode_builder/getdeps/envfuncs.py b/build/fbcode_builder/getdeps/envfuncs.py index 34e46afcd..496044b39 100644 --- a/build/fbcode_builder/getdeps/envfuncs.py +++ b/build/fbcode_builder/getdeps/envfuncs.py @@ -121,10 +121,10 @@ class Env(object): def add_path_entry(env, name, item, append=True, separator=os.pathsep): - """ Cause `item` to be added to the path style env var named + """Cause `item` to be added to the path style env var named `name` held in the `env` dict. `append` specifies whether the item is added to the end (the default) or should be - prepended if `name` already exists. """ + prepended if `name` already exists.""" val = env.get(name, "") if len(val) > 0: val = val.split(separator) @@ -138,10 +138,10 @@ def add_path_entry(env, name, item, append=True, separator=os.pathsep): def add_flag(env, name, flag, append=True): - """ Cause `flag` to be added to the CXXFLAGS-style env var named + """Cause `flag` to be added to the CXXFLAGS-style env var named `name` held in the `env` dict. `append` specifies whether the flag is added to the end (the default) or should be prepended if - `name` already exists. """ + `name` already exists.""" val = shlex.split(env.get(name, "")) if append: val.append(flag) @@ -155,11 +155,11 @@ _not_found = object() def path_search(env, exename, defval=None): - """ Search for exename in the PATH specified in env. + """Search for exename in the PATH specified in env. exename is eg: `ninja` and this function knows to append a .exe to the end on windows. Returns the path to the exe if found, or None if either no - PATH is set in env or no executable is found. """ + PATH is set in env or no executable is found.""" path = env.get("PATH", None) if path is None: diff --git a/build/fbcode_builder/getdeps/errors.py b/build/fbcode_builder/getdeps/errors.py index 1a1d1abca..3fad1a1de 100644 --- a/build/fbcode_builder/getdeps/errors.py +++ b/build/fbcode_builder/getdeps/errors.py @@ -7,9 +7,9 @@ from __future__ import absolute_import, division, print_function, unicode_litera class TransientFailure(Exception): - """ Raising this error causes getdeps to return with an error code + """Raising this error causes getdeps to return with an error code that Sandcastle will consider to be a retryable transient - infrastructure error """ + infrastructure error""" pass diff --git a/build/fbcode_builder/getdeps/expr.py b/build/fbcode_builder/getdeps/expr.py index e920231e3..6c0485d03 100644 --- a/build/fbcode_builder/getdeps/expr.py +++ b/build/fbcode_builder/getdeps/expr.py @@ -10,7 +10,7 @@ import shlex def parse_expr(expr_text, valid_variables): - """ parses the simple criteria expression syntax used in + """parses the simple criteria expression syntax used in dependency specifications. Returns an ExprNode instance that can be evaluated like this: diff --git a/build/fbcode_builder/getdeps/fetcher.py b/build/fbcode_builder/getdeps/fetcher.py index af423f56f..ef552d860 100644 --- a/build/fbcode_builder/getdeps/fetcher.py +++ b/build/fbcode_builder/getdeps/fetcher.py @@ -46,7 +46,7 @@ def file_name_is_cmake_file(file_name): class ChangeStatus(object): - """ Indicates the nature of changes that happened while updating + """Indicates the nature of changes that happened while updating the source directory. There are two broad uses: * When extracting archives for third party software we want to know that we did something (eg: we either extracted code or @@ -59,9 +59,9 @@ class ChangeStatus(object): """ def __init__(self, all_changed=False): - """ Construct a ChangeStatus object. The default is to create + """Construct a ChangeStatus object. The default is to create a status that indicates no changes, but passing all_changed=True - will create one that indicates that everything changed """ + will create one that indicates that everything changed""" if all_changed: self.source_files = 1 self.make_files = 1 @@ -70,7 +70,7 @@ class ChangeStatus(object): self.make_files = 0 def record_change(self, file_name): - """ Used by the shipit fetcher to record changes as it updates + """Used by the shipit fetcher to record changes as it updates files in the destination. If the file name might be one used in the cmake build system that we use for 1st party code, then record that as a "make file" change. We could broaden this @@ -79,7 +79,7 @@ class ChangeStatus(object): If the file isn't a build file and is under the `fbcode_builder` dir then we don't class that as an interesting change that we might need to rebuild, so we ignore it. - Otherwise we record the file as a source file change. """ + Otherwise we record the file as a source file change.""" file_name = file_name.lower() if file_name_is_cmake_file(file_name): @@ -90,41 +90,41 @@ class ChangeStatus(object): self.source_files += 1 def sources_changed(self): - """ Returns true if any source files were changed during + """Returns true if any source files were changed during an update operation. This will typically be used to decide that the build system to be run on the source dir in an - incremental mode """ + incremental mode""" return self.source_files > 0 def build_changed(self): - """ Returns true if any build files were changed during + """Returns true if any build files were changed during an update operation. This will typically be used to decidfe that the build system should be reconfigured and re-run - as a full build """ + as a full build""" return self.make_files > 0 class Fetcher(object): - """ The Fetcher is responsible for fetching and extracting the + """The Fetcher is responsible for fetching and extracting the sources for project. The Fetcher instance defines where the extracted data resides and reports this to the consumer via - its `get_src_dir` method. """ + its `get_src_dir` method.""" def update(self): - """ Brings the src dir up to date, ideally minimizing + """Brings the src dir up to date, ideally minimizing changes so that a subsequent build doesn't over-build. Returns a ChangeStatus object that helps the caller to understand the nature of the changes required during - the update. """ + the update.""" return ChangeStatus() def clean(self): - """ Reverts any changes that might have been made to - the src dir """ + """Reverts any changes that might have been made to + the src dir""" pass def hash(self): - """ Returns a hash that identifies the version of the code in the + """Returns a hash that identifies the version of the code in the working copy. For a git repo this is commit hash for the working copy. For other Fetchers this should relate to the version of the code in the src dir. The intent is that if a manifest @@ -137,17 +137,17 @@ class Fetcher(object): pass def get_src_dir(self): - """ Returns the source directory that the project was - extracted into """ + """Returns the source directory that the project was + extracted into""" pass class LocalDirFetcher(object): - """ This class exists to override the normal fetching behavior, and + """This class exists to override the normal fetching behavior, and use an explicit user-specified directory for the project sources. This fetcher cannot update or track changes. It always reports that the - project has changed, forcing it to always be built. """ + project has changed, forcing it to always be built.""" def __init__(self, path): self.path = os.path.realpath(path) @@ -337,9 +337,9 @@ def does_file_need_update(src_name, src_st, dest_name): def copy_if_different(src_name, dest_name): - """ Copy src_name -> dest_name, but only touch dest_name + """Copy src_name -> dest_name, but only touch dest_name if src_name is different from dest_name, making this a - more build system friendly way to copy. """ + more build system friendly way to copy.""" src_st = os.lstat(src_name) if not does_file_need_update(src_name, src_st, dest_name): return False @@ -379,9 +379,9 @@ class ShipitPathMap(object): self.exclusion = [] def add_mapping(self, fbsource_dir, target_dir): - """ Add a posix path or pattern. We cannot normpath the input + """Add a posix path or pattern. We cannot normpath the input here because that would change the paths from posix to windows - form and break the logic throughout this class. """ + form and break the logic throughout this class.""" self.roots.append(fbsource_dir) self.mapping.append((fbsource_dir, target_dir)) @@ -389,9 +389,9 @@ class ShipitPathMap(object): self.exclusion.append(re.compile(pattern)) def _minimize_roots(self): - """ compute the de-duplicated set of roots within fbsource. + """compute the de-duplicated set of roots within fbsource. We take the shortest common directory prefix to make this - determination """ + determination""" self.roots.sort(key=len) minimized = [] @@ -496,10 +496,10 @@ FBSOURCE_REPO_DATA: Dict[str, FbsourceRepoData] = {} def get_fbsource_repo_data(build_options): - """ Returns the commit metadata for the fbsource repo. + """Returns the commit metadata for the fbsource repo. Since we may have multiple first party projects to hash, and because we don't mutate the repo, we cache - this hash in a global. """ + this hash in a global.""" cached_data = FBSOURCE_REPO_DATA.get(build_options.fbsource_dir) if cached_data: return cached_data diff --git a/build/fbcode_builder/getdeps/load.py b/build/fbcode_builder/getdeps/load.py index 8f3f84c7a..40685511c 100644 --- a/build/fbcode_builder/getdeps/load.py +++ b/build/fbcode_builder/getdeps/load.py @@ -103,8 +103,8 @@ def patch_loader(namespace, manifests_dir="manifests"): def load_project(build_opts, project_name): - """ given the name of a project or a path to a manifest file, - load up the ManifestParser instance for it and return it """ + """given the name of a project or a path to a manifest file, + load up the ManifestParser instance for it and return it""" return LOADER.load_project(build_opts, project_name) @@ -113,7 +113,7 @@ def load_all_manifests(build_opts): class ManifestLoader(object): - """ ManifestLoader stores information about project manifest relationships for a + """ManifestLoader stores information about project manifest relationships for a given set of (build options + platform) configuration. The ManifestLoader class primarily serves as a location to cache project dependency @@ -159,7 +159,7 @@ class ManifestLoader(object): return self.manifests_by_name def manifests_in_dependency_order(self, manifest=None): - """ Compute all dependencies of the specified project. Returns a list of the + """Compute all dependencies of the specified project. Returns a list of the dependencies plus the project itself, in topologically sorted order. Each entry in the returned list only depends on projects that appear before it @@ -168,7 +168,7 @@ class ManifestLoader(object): If the input manifest is None, the dependencies for all currently loaded projects will be computed. i.e., if you call load_all_manifests() followed by manifests_in_dependency_order() this will return a global dependency ordering of - all projects. """ + all projects.""" # The list of deps that have been fully processed seen = set() # The list of deps which have yet to be evaluated. This @@ -258,12 +258,12 @@ class ManifestLoader(object): return h def _compute_project_hash(self, manifest): - """ This recursive function computes a hash for a given manifest. + """This recursive function computes a hash for a given manifest. The hash takes into account some environmental factors on the host machine and includes the hashes of its dependencies. No caching of the computation is performed, which is theoretically wasteful but the computation is fast enough that it is not required - to cache across multiple invocations. """ + to cache across multiple invocations.""" ctx = self.ctx_gen.get_context(manifest.name) hasher = hashlib.sha256() diff --git a/build/fbcode_builder/getdeps/manifest.py b/build/fbcode_builder/getdeps/manifest.py index 95e1c3b99..1094deb97 100644 --- a/build/fbcode_builder/getdeps/manifest.py +++ b/build/fbcode_builder/getdeps/manifest.py @@ -242,7 +242,7 @@ class ManifestParser(object): return defval def get_section_as_args(self, section, ctx=None): - """ Intended for use with the make.[build_args/install_args] and + """Intended for use with the make.[build_args/install_args] and autoconf.args sections, this method collects the entries and returns an array of strings. If the manifest contains conditional sections, ctx is used to @@ -267,8 +267,8 @@ class ManifestParser(object): return args def get_section_as_ordered_pairs(self, section, ctx=None): - """ Used for eg: shipit.pathmap which has strong - ordering requirements """ + """Used for eg: shipit.pathmap which has strong + ordering requirements""" res = [] ctx = ctx or {} @@ -302,13 +302,13 @@ class ManifestParser(object): return d def update_hash(self, hasher, ctx): - """ Compute a hash over the configuration for the given + """Compute a hash over the configuration for the given context. The goal is for the hash to change if the config for that context changes, but not if a change is made to the config only for a different platform than that expressed by ctx. The hash is intended to be used to help invalidate a future cache for the third party build products. - The hasher argument is a hash object returned from hashlib. """ + The hasher argument is a hash object returned from hashlib.""" for section in sorted(SCHEMA.keys()): hasher.update(section.encode("utf-8")) @@ -521,7 +521,7 @@ class ManifestParser(object): class ManifestContext(object): - """ ProjectContext contains a dictionary of values to use when evaluating boolean + """ProjectContext contains a dictionary of values to use when evaluating boolean expressions in a project manifest. This object should be passed as the `ctx` parameter in ManifestParser.get() calls. @@ -551,10 +551,10 @@ class ManifestContext(object): class ContextGenerator(object): - """ ContextGenerator allows creating ManifestContext objects on a per-project basis. + """ContextGenerator allows creating ManifestContext objects on a per-project basis. This allows us to evaluate different projects with slightly different contexts. - For instance, this can be used to only enable tests for some projects. """ + For instance, this can be used to only enable tests for some projects.""" def __init__(self, default_ctx): self.default_ctx = ManifestContext(default_ctx) diff --git a/build/fbcode_builder/getdeps/platform.py b/build/fbcode_builder/getdeps/platform.py index 0f79bb139..0369d0ca0 100644 --- a/build/fbcode_builder/getdeps/platform.py +++ b/build/fbcode_builder/getdeps/platform.py @@ -11,8 +11,8 @@ import sys def is_windows(): - """ Returns true if the system we are currently running on - is a Windows system """ + """Returns true if the system we are currently running on + is a Windows system""" return sys.platform.startswith("win")