mirror of
				https://github.com/pytorch/pytorch.git
				synced 2025-11-04 16:04:58 +08:00 
			
		
		
		
	[Code Clean] Remove deadcodes about Python3.9 [4/N] (#163643)
As the title stated. Pull Request resolved: https://github.com/pytorch/pytorch/pull/163643 Approved by: https://github.com/albanD ghstack dependencies: #163626, #163627, #163629
This commit is contained in:
		@ -500,19 +500,10 @@ class CodeGen:
 | 
			
		||||
 | 
			
		||||
                origin_typename = add_global(_type_repr(origin_type), origin_type)
 | 
			
		||||
 | 
			
		||||
                if hasattr(o, "__args__"):
 | 
			
		||||
                    # Assign global names for each of the inner type variables.
 | 
			
		||||
                if hasattr(o, "__args__") and o.__args__:
 | 
			
		||||
                    args = [type_repr(arg) for arg in o.__args__]
 | 
			
		||||
 | 
			
		||||
                    if len(args) == 0:
 | 
			
		||||
                        # Bare type, such as `typing.Tuple` with no subscript
 | 
			
		||||
                        # This code-path used in Python < 3.9
 | 
			
		||||
                        return origin_typename
 | 
			
		||||
 | 
			
		||||
                    return f"{origin_typename}[{','.join(args)}]"
 | 
			
		||||
                else:
 | 
			
		||||
                    # Bare type, such as `typing.Tuple` with no subscript
 | 
			
		||||
                    # This code-path used in Python 3.9+
 | 
			
		||||
                    return origin_typename
 | 
			
		||||
 | 
			
		||||
            # Common case: this is a regular module name like 'foo.bar.baz'
 | 
			
		||||
 | 
			
		||||
@ -37,7 +37,7 @@ T = TypeVar("T", bound=Union[int, float, bool, None, str, list, set, tuple, dict
 | 
			
		||||
_UNSET_SENTINEL = object()
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@dataclass
 | 
			
		||||
@dataclass(kw_only=True)
 | 
			
		||||
class _Config(Generic[T]):
 | 
			
		||||
    """Represents a config with richer behaviour than just a default value.
 | 
			
		||||
    ::
 | 
			
		||||
@ -81,32 +81,23 @@ class _Config(Generic[T]):
 | 
			
		||||
    justknob: Optional[str] = None
 | 
			
		||||
    env_name_default: Optional[list[str]] = None
 | 
			
		||||
    env_name_force: Optional[list[str]] = None
 | 
			
		||||
    value_type: Optional[type] = None
 | 
			
		||||
    alias: Optional[str] = None
 | 
			
		||||
 | 
			
		||||
    def __init__(
 | 
			
		||||
        self,
 | 
			
		||||
        default: Union[T, object] = _UNSET_SENTINEL,
 | 
			
		||||
        justknob: Optional[str] = None,
 | 
			
		||||
        env_name_default: Optional[Union[str, list[str]]] = None,
 | 
			
		||||
        env_name_force: Optional[Union[str, list[str]]] = None,
 | 
			
		||||
        value_type: Optional[type] = None,
 | 
			
		||||
        alias: Optional[str] = None,
 | 
			
		||||
    ):
 | 
			
		||||
        # python 3.9 does not support kw_only on the dataclass :(.
 | 
			
		||||
        self.default = default
 | 
			
		||||
        self.justknob = justknob
 | 
			
		||||
    def __post_init__(self) -> None:
 | 
			
		||||
        self.env_name_default = _Config.string_or_list_of_string_to_list(
 | 
			
		||||
            env_name_default
 | 
			
		||||
            self.env_name_default
 | 
			
		||||
        )
 | 
			
		||||
        self.env_name_force = _Config.string_or_list_of_string_to_list(env_name_force)
 | 
			
		||||
        self.value_type = value_type
 | 
			
		||||
        self.alias = alias
 | 
			
		||||
        self.env_name_force = _Config.string_or_list_of_string_to_list(
 | 
			
		||||
            self.env_name_force
 | 
			
		||||
        )
 | 
			
		||||
 | 
			
		||||
        if self.alias is not None:
 | 
			
		||||
            assert (
 | 
			
		||||
                default is _UNSET_SENTINEL
 | 
			
		||||
                and justknob is None
 | 
			
		||||
                and env_name_default is None
 | 
			
		||||
                and env_name_force is None
 | 
			
		||||
                self.default is _UNSET_SENTINEL
 | 
			
		||||
                and self.justknob is None
 | 
			
		||||
                and self.env_name_default is None
 | 
			
		||||
                and self.env_name_force is None
 | 
			
		||||
            ), "if alias is set, none of {default, justknob and env var} can be set"
 | 
			
		||||
 | 
			
		||||
    @staticmethod
 | 
			
		||||
@ -147,7 +138,12 @@ else:
 | 
			
		||||
        alias: Optional[str] = None,
 | 
			
		||||
    ) -> _Config[T]:
 | 
			
		||||
        return _Config(
 | 
			
		||||
            default, justknob, env_name_default, env_name_force, value_type, alias
 | 
			
		||||
            default=default,
 | 
			
		||||
            justknob=justknob,
 | 
			
		||||
            env_name_default=env_name_default,
 | 
			
		||||
            env_name_force=env_name_force,
 | 
			
		||||
            value_type=value_type,
 | 
			
		||||
            alias=alias,
 | 
			
		||||
        )
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -345,7 +345,7 @@ PLAT_TO_VCVARS = {
 | 
			
		||||
    'win-amd64' : 'x86_amd64',
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
min_supported_cpython = "0x03090000"  # Python 3.9 hexcode
 | 
			
		||||
min_supported_cpython = "0x030A0000"  # Python 3.10 hexcode
 | 
			
		||||
 | 
			
		||||
def get_cxx_compiler():
 | 
			
		||||
    if IS_WINDOWS:
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user