Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions Lib/venv/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,15 +90,17 @@ def create(self, env_dir):
if self.upgrade_deps:
self.upgrade_dependencies(context)

def clear_directory(self, path):
@staticmethod
Copy link
Contributor

@rruuaanng rruuaanng Sep 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems that's this @staticmethod has no substantial effect. I don't think it's necessary.

def clear_directory(path):
for fn in os.listdir(path):
fn = os.path.join(path, fn)
if os.path.islink(fn) or os.path.isfile(fn):
os.remove(fn)
elif os.path.isdir(fn):
shutil.rmtree(fn)

def _venv_path(self, env_dir, name):
@staticmethod
def _venv_path(env_dir, name):
vars = {
'base': env_dir,
'platbase': env_dir,
Expand Down Expand Up @@ -275,7 +277,8 @@ def symlink_or_copy(self, src, dst, relative_symlinks_ok=False):
if force_copy:
shutil.copyfile(src, dst)

def create_git_ignore_file(self, context):
@staticmethod
def create_git_ignore_file(context):
"""
Create a .gitignore file in the environment directory.

Expand Down Expand Up @@ -425,7 +428,8 @@ def setup_python(self, context):
shutil.copyfile(src, dst)
break

def _call_new_python(self, context, *py_args, **kwargs):
@staticmethod
def _call_new_python(context, *py_args, **kwargs):
"""Executes the newly created Python using safe-ish options"""
# gh-98251: We do not want to just use '-I' because that masks
# legitimate user preferences (such as not writing bytecode). All we
Expand Down Expand Up @@ -470,7 +474,8 @@ def post_setup(self, context):
"""
pass

def replace_variables(self, text, context):
@staticmethod
def replace_variables(text, context):
"""
Replace variable placeholders in script text with context-specific
variables.
Expand Down
Loading