mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-21 05:34:18 +08:00
[torchgen] Refactor torchgen.utils.FileManager
to accept pathlib.Path
(#150726)
This PR allows `FileManager` to accept `pathlib.Path` as arguments while keeping the original `str` path support. This allows us to simplify the code such as: 1. `os.path.join(..., ...)` with `Path.__floordiv__(..., ...)`.95a5958db4/torchgen/utils.py (L155)
95a5958db4/torchgen/utils.py (L176)
2. `os.path.basename(...)` with `Path(...).name`.95a5958db4/torchgen/utils.py (L161)
3. Manual file extension split with `Path(...).with_stem(new_stem)`95a5958db4/torchgen/utils.py (L241-L256)
------ Pull Request resolved: https://github.com/pytorch/pytorch/pull/150726 Approved by: https://github.com/aorenste
This commit is contained in:
committed by
PyTorch MergeBot
parent
881a598a1e
commit
014726d9d3
@ -6,8 +6,9 @@ import re
|
||||
from dataclasses import dataclass
|
||||
from enum import auto, Enum
|
||||
from typing import Callable, Optional, TYPE_CHECKING
|
||||
from typing_extensions import assert_never
|
||||
|
||||
from torchgen.utils import assert_never, NamespaceHelper, OrderedSet
|
||||
from torchgen.utils import NamespaceHelper, OrderedSet
|
||||
|
||||
|
||||
if TYPE_CHECKING:
|
||||
|
Reference in New Issue
Block a user