mirror of
https://github.com/rust-lang/rust.git
synced 2024-10-29 21:41:47 +00:00
Fix recent python linting errors
- Remove unneeded imports in 'fuscia-test-runner.py' - Add explicit stacklevel to 'x.py' - Fix mutable types as default args in `bootstrap.py` and `bootstrap_test.py`
This commit is contained in:
parent
efc49e4dfa
commit
9df0f5d433
@ -472,7 +472,9 @@ class FakeArgs:
|
||||
|
||||
class RustBuild(object):
|
||||
"""Provide all the methods required to build Rust"""
|
||||
def __init__(self, config_toml="", args=FakeArgs()):
|
||||
def __init__(self, config_toml="", args=None):
|
||||
if args is None:
|
||||
args = FakeArgs()
|
||||
self.git_version = None
|
||||
self.nix_deps_dir = None
|
||||
self._should_fix_bins_and_dylibs = None
|
||||
|
@ -4,7 +4,6 @@ Run these with `x test bootstrap`, or `python -m unittest src/bootstrap/bootstra
|
||||
|
||||
from __future__ import absolute_import, division, print_function
|
||||
import os
|
||||
import doctest
|
||||
import unittest
|
||||
import tempfile
|
||||
import hashlib
|
||||
@ -16,12 +15,15 @@ from shutil import rmtree
|
||||
bootstrap_dir = os.path.dirname(os.path.abspath(__file__))
|
||||
# For the import below, have Python search in src/bootstrap first.
|
||||
sys.path.insert(0, bootstrap_dir)
|
||||
import bootstrap
|
||||
import configure
|
||||
import bootstrap # noqa: E402
|
||||
import configure # noqa: E402
|
||||
|
||||
def serialize_and_parse(configure_args, bootstrap_args=bootstrap.FakeArgs()):
|
||||
def serialize_and_parse(configure_args, bootstrap_args=None):
|
||||
from io import StringIO
|
||||
|
||||
if bootstrap_args is None:
|
||||
bootstrap_args = bootstrap.FakeArgs()
|
||||
|
||||
section_order, sections, targets = configure.parse_args(configure_args)
|
||||
buffer = StringIO()
|
||||
configure.write_config_toml(buffer, section_order, targets, sections)
|
||||
@ -129,7 +131,14 @@ class GenerateAndParseConfig(unittest.TestCase):
|
||||
class BuildBootstrap(unittest.TestCase):
|
||||
"""Test that we generate the appropriate arguments when building bootstrap"""
|
||||
|
||||
def build_args(self, configure_args=[], args=[], env={}):
|
||||
def build_args(self, configure_args=None, args=None, env=None):
|
||||
if configure_args is None:
|
||||
configure_args = []
|
||||
if args is None:
|
||||
args = []
|
||||
if env is None:
|
||||
env = {}
|
||||
|
||||
env = env.copy()
|
||||
env["PATH"] = os.environ["PATH"]
|
||||
|
||||
|
@ -15,12 +15,10 @@ import hashlib
|
||||
import json
|
||||
import os
|
||||
import platform
|
||||
import re
|
||||
import shutil
|
||||
import signal
|
||||
import subprocess
|
||||
import sys
|
||||
from typing import ClassVar, List, Optional
|
||||
from typing import ClassVar, List
|
||||
|
||||
|
||||
@dataclass
|
||||
@ -523,7 +521,7 @@ class TestEnvironment:
|
||||
env_vars += '\n "RUST_BACKTRACE=0",'
|
||||
|
||||
# Use /tmp as the test temporary directory
|
||||
env_vars += f'\n "RUST_TEST_TMPDIR=/tmp",'
|
||||
env_vars += '\n "RUST_TEST_TMPDIR=/tmp",'
|
||||
|
||||
cml.write(
|
||||
self.CML_TEMPLATE.format(env_vars=env_vars, exe_name=exe_name)
|
||||
|
2
x.py
2
x.py
@ -40,7 +40,7 @@ if __name__ == '__main__':
|
||||
|
||||
This message can be suppressed by setting `RUST_IGNORE_OLD_PYTHON=1`
|
||||
""".format(major, minor))
|
||||
warnings.warn(msg)
|
||||
warnings.warn(msg, stacklevel=1)
|
||||
|
||||
rust_dir = os.path.dirname(os.path.abspath(__file__))
|
||||
# For the import below, have Python search in src/bootstrap first.
|
||||
|
Loading…
Reference in New Issue
Block a user