1# Copyright (c) 2025 Huawei Device Co., Ltd. 2# Licensed under the Apache License, Version 2.0 (the "License"); 3# you may not use this file except in compliance with the License. 4# You may obtain a copy of the License at 5# 6# http://www.apache.org/licenses/LICENSE-2.0 7# 8# Unless required by applicable law or agreed to in writing, software 9# distributed under the License is distributed on an "AS IS" BASIS, 10# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11# See the License for the specific language governing permissions and 12# limitations under the License. 13 14[project] 15# dynamic = ["version"] 16name = "taihe" 17description = "Language-neutral API tooling" 18requires-python = ">=3.10" 19dependencies = [ 20 "antlr4-python3-runtime>=4.13.2", 21 "typing-extensions>=4.13.2", 22] 23version = "0.34.1" 24 25[dependency-groups] 26dev = [ 27 "black>=25.1.0", 28 "coverage>=7.8.0", 29 "pyright>=1.1.400", 30 "pytest>=8.3.5", 31 "removestar>=1.5.2", 32 "ruff>=0.11.6", 33] 34 35[[tool.uv.index]] 36url = "https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple/" 37default = true 38 39### Build System ### 40 41[build-system] 42requires = ["hatchling", "hatch-vcs"] 43build-backend = "hatchling.build" 44 45[project.scripts] 46taihec = "taihe.cli.compiler:main" 47taihe-tryit = "taihe.cli.tryit:main" 48 49[tool.hatch.version] 50source = "vcs" 51 52[tool.hatch.version.raw-options] 53search_parent_directories = true 54local_scheme = "dirty-tag" 55version_scheme = "python-simplified-semver" 56 57[tool.hatch.build.hooks.vcs] 58version-file = "taihe/_version.py" 59 60### Linting ### 61 62[tool.black] 63exclude = "(taihe/parse/antlr|taihe/_version.py)" 64target-version = ['py310'] 65 66[tool.pyright] 67include = ["taihe"] 68exclude = ["taihe/parse/antlr"] 69pythonVersion = '3.10' 70 71# strict = ["taihe"] # Maybe later: codegen 72strict = ["taihe/cli", "taihe/driver", "taihe/parse", "taihe/semantics", "taihe/utils"] 73 74### Linting (Ruff Only) ### 75 76[tool.ruff] 77target-version = 'py310' 78 79# Don't check generated code. 80exclude = ["taihe/parse/antlr/*.py", "taihe/_version.py"] 81 82# See all rules at https://beta.ruff.rs/docs/rules/ 83lint.select = [ 84 "E", # pycodestyle 85 "W", # pycodestyle 86 "F", # Pyflakes 87 "B", # flake8-bugbear 88 "C4", # flake8-comprehensions 89 "D", # pydocstyle 90 "I", # isort 91 "SIM", # flake8-simplify 92 "TCH", # flake8-type-checking 93 "TID", # flake8-tidy-imports 94 "Q", # flake8-quotes 95 "UP", # pyupgrade 96 "PT", # flake8-pytest-style 97 "RUF", # Ruff-specific rules 98] 99 100lint.ignore = [ 101 "E501", # "Line too long" 102 # -> "line length already regulated by black" 103 "PT011", # "pytest.raises() should specify expected exception" 104 # -> "would imply to update tests every time you update exception message" 105 "SIM108", 106 "F541", # "f-string without any placeholders" 107 "E731", 108 "D100", 109 "D101", 110 "D102", 111 "D103", 112 "D104", 113 "D105", 114 "D106", 115 "D107", # "Missing docstring in public function too restrictive" 116 "SIM117", # allow multiple `with` statements in code generator 117 "TC001", 118 "TC002", 119 "TC003", # "unnecessary to move to a TYPE_CHECKING block" 120 "TC006", 121 "B007", 122] 123 124[tool.ruff.lint.pydocstyle] 125# Automatically disable rules that are incompatible with Google docstring convention 126convention = "google" 127 128[tool.ruff.lint.pycodestyle] 129max-doc-length = 100 130 131[tool.ruff.lint.flake8-tidy-imports] 132ban-relative-imports = "all" 133 134[tool.ruff.lint.flake8-type-checking] 135strict = true 136runtime-evaluated-base-classes = ["pydantic.BaseModel"] 137# Pydantic needs to be able to evaluate types at runtime 138# see https://pypi.org/project/flake8-type-checking/ for flake8-type-checking documentation 139# see https://beta.ruff.rs/docs/settings/#flake8-type-checking-runtime-evaluated-base-classes for ruff documentation 140