This is an automated email from the ASF dual-hosted git repository.

nchammas pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/spark.git


The following commit(s) were added to refs/heads/master by this push:
     new 33effd54b939 [SPARK-58845][PYTHON] Collapse check-then-create-dir 
pattern into single call
33effd54b939 is described below

commit 33effd54b939224902513cf8909bd676e399abe7
Author: Nicholas Chammas <[email protected]>
AuthorDate: Wed Aug 19 09:03:51 2026 -0400

    [SPARK-58845][PYTHON] Collapse check-then-create-dir pattern into single 
call
    
    ### What changes were proposed in this pull request?
    
    Instead of checking whether a directory exists before calling 
`os.makedirs`, simply pass `exist_ok=True`.
    
    ### Why are the changes needed?
    
    Simpler, more idiomatic use of the Python standard library.
    
    ### Does this PR introduce _any_ user-facing change?
    
    No.
    
    ### How was this patch tested?
    
    Existing CI tests.
    
    ### Was this patch authored or co-authored using generative AI tooling?
    
    No.
    
    Closes #58032 from nchammas/makedirs-exist-ok.
    
    Authored-by: Nicholas Chammas <[email protected]>
    Signed-off-by: Nicholas Chammas <[email protected]>
---
 python/packaging/classic/setup.py | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/python/packaging/classic/setup.py 
b/python/packaging/classic/setup.py
index 37f71d1bddcb..23c20d2c54b7 100755
--- a/python/packaging/classic/setup.py
+++ b/python/packaging/classic/setup.py
@@ -206,11 +206,7 @@ try:
     # We copy the shell script to be under pyspark/python/pyspark so that the 
launcher scripts
     # find it where expected. The rest of the files aren't copied because they 
are accessed
     # using Python imports instead which will be resolved correctly.
-    try:
-        os.makedirs("pyspark/python/pyspark")
-    except OSError:
-        # Don't worry if the directory already exists.
-        pass
+    os.makedirs("pyspark/python/pyspark", exist_ok=True)
     copyfile("pyspark/shell.py", "pyspark/python/pyspark/shell.py")
 
     if in_spark:


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to