This repository was archived by the owner on Feb 2, 2026. It is now read-only.
fix: prevent TypeError when gdriveutils is imported before arg_parser#141
Open
UsamaFoad wants to merge 1 commit into
Open
fix: prevent TypeError when gdriveutils is imported before arg_parser#141UsamaFoad wants to merge 1 commit into
UsamaFoad wants to merge 1 commit into
Conversation
The gdriveutils module was triggering a TypeError during initialization because it attempted to validate `cli_param.gd_path` before the command-line arguments had been parsed. Root Cause: In `cps/gdriveutils.py`, `os.path.exists()` is called on `cli_param.gd_path` at the module level. Since `CliParameter` initializes `gd_path` as `None`, and the import occurs before `arg_parser()` is executed, the `stat` system call fails. Changes: - Added a null check for `cli_param.gd_path` in `cps/gdriveutils.py`. - The logic now safely handles cases where Google Drive paths are not yet initialized or are explicitly disabled. Traceback reference: TypeError: stat: path should be string, bytes, os.PathLike or integer, not NoneType
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
[PR] Fix TypeError in gdriveutils during module initialization
name:
fix: prevent TypeError when gdriveutils is imported before arg_parserlabels:
["bug", "review"]projects:
gelbphoenix/2Description
Fixed a
TypeErroroccurring incps/gdriveutils.pywhereos.path.exists()was called on aNoneTypevariable. This happened because the module was being imported (and thus executing module-level code) before the command-line arguments were parsed andcli_param.gd_pathwas initialized.Added short-circuit logic to verify
gd_pathis notNonebefore attempting to check for the path's existence.Type of Change
Areas Affected
How Has This Been Tested?
from cps.editbooks import editbooknow completes successfully without a traceback.Test Configuration
Screenshots/Video (if applicable)
N/A - This is a backend fix for a silent crash during import.
Checklist
Related Issues
Fixes: Discovered during development; no existing issue tracked
Additional Notes
The root cause was the order of operations:
editbooks.pyimportsgdriveutils.py, which immediately checks the filesystem for a path thatcli.pyhasn't had the chance to populate yet. This fix ensures the app remains stable during the early boot phase.The
gdriveutilsmodule was triggering aTypeErrorduring initialization because it attempted to validatecli_param.gd_pathbefore the command-line arguments had been parsed.Root Cause:
In
cps/gdriveutils.py,os.path.exists()is called oncli_param.gd_pathat the module level. SinceCliParameterinitializesgd_pathasNone, and the import occurs beforearg_parser()is executed, thestatsystem call fails.Changes:
cli_param.gd_pathincps/gdriveutils.py.Traceback reference:
TypeError: stat: path should be string, bytes, os.PathLike or integer, not NoneType