Skip to content

Commit 68aa962

Browse files
authored
Fix type hint on Python 3.8 (#4862)
Use typing instead on bare Python type to avoid using subscript operation on built-in Python type Fix "TypeError: 'type' object is not subscriptable" error on Python 3.8 The core Triton is a small number of people, and we receive many PRs (thank you!). To help us review your code more quickly, **if you are a new contributor (less than 3 PRs merged) we ask that you complete the following tasks and include the filled-out checklist in your PR description.** Complete the following tasks before sending your PR, and replace `[ ]` with `[x]` to indicate you have done them. - [x] I am not making a trivial change, such as fixing a typo in a comment. - [x] I have written a PR description following these [rules](https://cbea.ms/git-commit/#why-not-how). - [x] I have run `pre-commit run --from-ref origin/main --to-ref HEAD`. - Select one of the following. - [ ] I have added tests. - `/test` for `lit` tests - `/unittest` for C++ tests - `/python/test` for end-to-end tests - [x] This PR does not need a test because `FILL THIS IN`. - Select one of the following. - [x] I have not added any `lit` tests. - [ ] The `lit` tests I have added follow these [best practices](https://mlir.llvm.org/getting_started/TestingGuide/#filecheck-best-practices), including the "tests should be minimal" section. (Usually running Python code and using the instructions it generates is not minimal.)
1 parent 82fae4e commit 68aa962

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

python/setup.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
from io import BytesIO
1515
from distutils.command.clean import clean
1616
from pathlib import Path
17-
from typing import NamedTuple
17+
from typing import List, NamedTuple
1818

1919
from setuptools import Extension, setup
2020
from setuptools.command.build_ext import build_ext
@@ -32,8 +32,8 @@
3232
@dataclass
3333
class Backend:
3434
name: str
35-
package_data: list[str]
36-
language_package_data: list[str]
35+
package_data: List[str]
36+
language_package_data: List[str]
3737
src_dir: str
3838
backend_dir: str
3939
language_dir: str

python/triton/backends/compiler.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
from abc import ABCMeta, abstractmethod, abstractclassmethod
77
from dataclasses import dataclass
8-
from typing import Dict, Union
8+
from typing import Dict, List, Tuple, Union
99
from types import ModuleType
1010

1111

@@ -146,7 +146,7 @@ def from_dict(data):
146146
return attrsDescriptor
147147

148148
@staticmethod
149-
def from_hints(hints: list[tuple[int, int]]):
149+
def from_hints(hints: List[Tuple[int, int]]):
150150
"""
151151
Create the class from a set of hints that are passed in.
152152

0 commit comments

Comments
 (0)