Skip to content

Commit

Permalink
Fix linting
Browse files Browse the repository at this point in the history
  • Loading branch information
fchollet committed Sep 13, 2024
1 parent 13dd42c commit 65e8051
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
14 changes: 7 additions & 7 deletions api_gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

import namex

package = "keras"
PACKAGE = "keras"
BUILD_DIR_NAME = "tmp_build_dir"


Expand All @@ -28,7 +28,7 @@ def copy_source_to_build_directory(root_path):
shutil.rmtree(build_dir)
os.mkdir(build_dir)
shutil.copytree(
package, os.path.join(build_dir, package), ignore=ignore_files
PACKAGE, os.path.join(build_dir, PACKAGE), ignore=ignore_files
)
return build_dir

Expand Down Expand Up @@ -163,12 +163,12 @@ def update_package_init(template_fname, dest_fname, api_module):
def build():
# Backup the `keras/__init__.py` and restore it on error in api gen.
root_path = os.path.dirname(os.path.abspath(__file__))
code_api_dir = os.path.join(root_path, package, "api")
code_init_fname = os.path.join(root_path, package, "__init__.py")
code_api_dir = os.path.join(root_path, PACKAGE, "api")
code_init_fname = os.path.join(root_path, PACKAGE, "__init__.py")
# Create temp build dir
build_dir = copy_source_to_build_directory(root_path)
build_api_dir = os.path.join(build_dir, package, "api")
build_init_fname = os.path.join(build_dir, package, "__init__.py")
build_api_dir = os.path.join(build_dir, PACKAGE, "api")
build_init_fname = os.path.join(build_dir, PACKAGE, "__init__.py")
build_api_init_fname = os.path.join(build_api_dir, "__init__.py")
try:
os.chdir(build_dir)
Expand All @@ -184,7 +184,7 @@ def build():
# Add __version__ to `api/`.
export_version_string(build_api_init_fname)
# Creates `_tf_keras` with full keras API
create_legacy_directory(package_dir=os.path.join(build_dir, package))
create_legacy_directory(package_dir=os.path.join(build_dir, PACKAGE))
# Update toplevel init with all `api/` imports.
api_module = importlib.import_module(f"{BUILD_DIR_NAME}.keras.api")
update_package_init(code_init_fname, build_init_fname, api_module)
Expand Down
7 changes: 4 additions & 3 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,11 @@ extend-exclude =
guides,


#imported but unused in __init__.py, that's ok.
per-file-ignores =
# import not used
**/__init__.py:F401
# imported but unused in __init__.py, that's ok.
**/__init__.py:E501,F401
**/random.py:F401
# Lines too long in API files
./keras/api/**/__init__.py:E501,F401

max-line-length = 80

0 comments on commit 65e8051

Please sign in to comment.