From 1ea8518411c44fdef1f51e7b65b11d77b8eb4a24 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 22 Apr 2022 14:55:10 +0800 Subject: [PATCH] [misc] Update pre-commit hooks (#4713) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * [pre-commit.ci] pre-commit autoupdate updates: - [github.com/google/yapf: v0.31.0 → v0.32.0](https://github.com/google/yapf/compare/v0.31.0...v0.32.0) - https://github.com/timothycrosley/isort → https://github.com/PyCQA/isort - [github.com/pre-commit/mirrors-clang-format: v10.0.1 → v13.0.1](https://github.com/pre-commit/mirrors-clang-format/compare/v10.0.1...v13.0.1) - [github.com/pre-commit/pre-commit-hooks: v4.0.1 → v4.1.0](https://github.com/pre-commit/pre-commit-hooks/compare/v4.0.1...v4.1.0) - [github.com/PyCQA/pylint: v2.13.1 → v2.13.4](https://github.com/PyCQA/pylint/compare/v2.13.1...v2.13.4) * Add style config for yapf 0.32 * Change the commit message to follow taichi's rule Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Frost Ming Co-authored-by: Ailing --- .pre-commit-config.yaml | 12 +++++++----- pyproject.toml | 1 + requirements_dev.txt | 2 +- taichi/backends/cc/cc_utils.h | 2 +- taichi/backends/cc/codegen_cc.cpp | 6 +++--- taichi/backends/cc/struct_cc.h | 2 +- taichi/backends/metal/codegen_metal.cpp | 2 +- taichi/backends/metal/struct_metal.cpp | 4 ++-- taichi/backends/opengl/codegen_opengl.cpp | 2 +- taichi/codegen/spirv/spirv_ir_builder.h | 20 ++++++++++---------- taichi/common/serialization.h | 4 ++-- taichi/ir/control_flow_graph.h | 2 +- taichi/ir/expr.h | 2 +- taichi/ir/expression.h | 2 +- taichi/ir/expression_printer.h | 2 +- taichi/ir/ir.h | 10 +++++----- taichi/ir/ir_builder.h | 2 +- taichi/ir/statements.h | 8 ++++---- taichi/jit/jit_module.h | 2 +- taichi/llvm/llvm_codegen_utils.h | 6 +++--- taichi/runtime/llvm/runtime.cpp | 8 ++++---- taichi/transforms/auto_diff.cpp | 2 +- taichi/transforms/ir_printer.cpp | 2 +- taichi/transforms/make_thread_local.cpp | 9 ++++----- taichi/util/line_appender.h | 2 +- taichi/util/meta.h | 6 +++--- 26 files changed, 62 insertions(+), 60 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 358e2afc8057cc..7c0fdf9f995d9a 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,32 +1,34 @@ ci: autoupdate_schedule: quarterly + autoupdate_commit_msg: '[misc] Update pre-commit hooks' exclude: ^((tests/python/test_exception|.*/examples/.*)\.py$|external/) repos: - repo: https://github.com/google/yapf - rev: v0.31.0 + rev: v0.32.0 hooks: - id: yapf additional_dependencies: [toml] - - repo: https://github.com/timothycrosley/isort + - repo: https://github.com/PyCQA/isort rev: 5.10.1 hooks: - id: isort - repo: https://github.com/pre-commit/mirrors-clang-format - rev: v10.0.1 + rev: v13.0.1 hooks: - id: clang-format + exclude: .*\.json$ - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.0.1 + rev: v4.1.0 hooks: - id: trailing-whitespace - id: end-of-file-fixer - repo: https://github.com/PyCQA/pylint - rev: v2.13.1 + rev: v2.13.4 hooks: - id: pylint args: ['-rn', '-sn'] diff --git a/pyproject.toml b/pyproject.toml index 5d988dda356370..c4a857f234460b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -12,3 +12,4 @@ filterwarnings = [ [tool.yapf] based_on_style = "pep8" +blank_line_before_nested_class_or_def = false diff --git a/requirements_dev.txt b/requirements_dev.txt index 89737bf90b8303..e8849dc3cb1aa2 100644 --- a/requirements_dev.txt +++ b/requirements_dev.txt @@ -4,7 +4,7 @@ coverage Pillow pybind11 GitPython -yapf==0.31.0 +yapf distro sourceinspect isort diff --git a/taichi/backends/cc/cc_utils.h b/taichi/backends/cc/cc_utils.h index 601dd19fedb74e..b7070622a436ed 100644 --- a/taichi/backends/cc/cc_utils.h +++ b/taichi/backends/cc/cc_utils.h @@ -73,7 +73,7 @@ inline std::string unary_op_type_symbol(UnaryOpType op) { } template -inline int execute(std::string fmt, Args &&... args) { +inline int execute(std::string fmt, Args &&...args) { auto cmd = fmt::format(fmt, std::forward(args)...); TI_TRACE("Executing command: {}", cmd); int ret = std::system(cmd.c_str()); diff --git a/taichi/backends/cc/codegen_cc.cpp b/taichi/backends/cc/codegen_cc.cpp index 3b54b129a81cd8..6f78f2182e7395 100644 --- a/taichi/backends/cc/codegen_cc.cpp +++ b/taichi/backends/cc/codegen_cc.cpp @@ -305,7 +305,7 @@ class CCTransformer : public IRVisitor { static inline std::string invoke_libc(std::string name, DataType dt, std::string const &fmt, - Args &&... args) { + Args &&...args) { auto arguments = fmt::format(fmt, std::forward(args)...); return invoke_libc(name, dt, arguments); } @@ -594,12 +594,12 @@ class CCTransformer : public IRVisitor { } template - void emit(std::string f, Args &&... args) { + void emit(std::string f, Args &&...args) { line_appender_.append(std::move(f), std::move(args)...); } template - void emit_header(std::string f, Args &&... args) { + void emit_header(std::string f, Args &&...args) { line_appender_header_.append(std::move(f), std::move(args)...); } }; // namespace cccp diff --git a/taichi/backends/cc/struct_cc.h b/taichi/backends/cc/struct_cc.h index cd89d94539c5f4..415fed2bfc7946 100644 --- a/taichi/backends/cc/struct_cc.h +++ b/taichi/backends/cc/struct_cc.h @@ -24,7 +24,7 @@ class CCLayoutGen { void generate_types(SNode *snode); template - void emit(std::string f, Args &&... args) { + void emit(std::string f, Args &&...args) { line_appender_.append(std::move(f), std::move(args)...); } diff --git a/taichi/backends/metal/codegen_metal.cpp b/taichi/backends/metal/codegen_metal.cpp index 9a65afbcc7621f..14bc796597aa1c 100644 --- a/taichi/backends/metal/codegen_metal.cpp +++ b/taichi/backends/metal/codegen_metal.cpp @@ -1610,7 +1610,7 @@ class KernelCodegenImpl : public IRVisitor { } template - void emit(std::string f, Args &&... args) { + void emit(std::string f, Args &&...args) { current_appender().append(std::move(f), std::forward(args)...); } diff --git a/taichi/backends/metal/struct_metal.cpp b/taichi/backends/metal/struct_metal.cpp index 15ef3ab10bb48a..ff280beafe45b7 100644 --- a/taichi/backends/metal/struct_metal.cpp +++ b/taichi/backends/metal/struct_metal.cpp @@ -345,7 +345,7 @@ class StructCompiler { } template - void emit(std::string f, Args &&... args) { + void emit(std::string f, Args &&...args) { line_appender_.append(std::move(f), std::move(args)...); } @@ -397,7 +397,7 @@ class RuntimeModuleCompiler { } template - void emit(std::string f, Args &&... args) { + void emit(std::string f, Args &&...args) { line_appender_.append(std::move(f), std::move(args)...); } diff --git a/taichi/backends/opengl/codegen_opengl.cpp b/taichi/backends/opengl/codegen_opengl.cpp index c6bb01d871faad..173d8cd1c8aee3 100644 --- a/taichi/backends/opengl/codegen_opengl.cpp +++ b/taichi/backends/opengl/codegen_opengl.cpp @@ -122,7 +122,7 @@ class KernelGen : public IRVisitor { std::unordered_set loaded_args_; template - void emit(std::string f, Args &&... args) { + void emit(std::string f, Args &&...args) { line_appender_.append(std::move(f), std::move(args)...); } diff --git a/taichi/codegen/spirv/spirv_ir_builder.h b/taichi/codegen/spirv/spirv_ir_builder.h index 353161852ab25f..481e7160c8247f 100644 --- a/taichi/codegen/spirv/spirv_ir_builder.h +++ b/taichi/codegen/spirv/spirv_ir_builder.h @@ -17,7 +17,7 @@ namespace spirv { template struct for_each_dispatcher { template - static void run(const F &f, T &&value, Args &&... args) { // NOLINT(*) + static void run(const F &f, T &&value, Args &&...args) { // NOLINT(*) f(I, std::forward(value)); for_each_dispatcher::run( f, std::forward(args)...); @@ -31,7 +31,7 @@ struct for_each_dispatcher { }; template -inline void for_each(const F &f, Args &&... args) { // NOLINT(*) +inline void for_each(const F &f, Args &&...args) { // NOLINT(*) for_each_dispatcher::run( f, std::forward(args)...); } @@ -165,7 +165,7 @@ class InstrBuilder { } template - InstrBuilder &add_seq(Args &&... args) { + InstrBuilder &add_seq(Args &&...args) { AddSeqHelper helper; helper.builder = this; for_each(helper, std::forward(args)...); @@ -207,29 +207,29 @@ class IRBuilder { } template - void debug(spv::Op op, Args &&... args) { + void debug(spv::Op op, Args &&...args) { ib_.begin(op).add_seq(std::forward(args)...).commit(&debug_); } template - void execution_mode(Value func, Args &&... args) { + void execution_mode(Value func, Args &&...args) { ib_.begin(spv::OpExecutionMode) .add_seq(func, std::forward(args)...) .commit(&exec_mode_); } template - void decorate(spv::Op op, Args &&... args) { + void decorate(spv::Op op, Args &&...args) { ib_.begin(op).add_seq(std::forward(args)...).commit(&decorate_); } template - void declare_global(spv::Op op, Args &&... args) { + void declare_global(spv::Op op, Args &&...args) { ib_.begin(op).add_seq(std::forward(args)...).commit(&global_); } template - Instr make_inst(spv::Op op, Args &&... args) { + Instr make_inst(spv::Op op, Args &&...args) { return ib_.begin(op) .add_seq(std::forward(args)...) .commit(&function_); @@ -267,7 +267,7 @@ class IRBuilder { // Make a new SSA value template - Value make_value(spv::Op op, const SType &out_type, Args &&... args) { + Value make_value(spv::Op op, const SType &out_type, Args &&...args) { Value val = new_value(out_type, ValueKind::kNormal); make_inst(op, out_type, val, std::forward(args)...); if (out_type.flag == TypeKind::kPtr) { @@ -422,7 +422,7 @@ class IRBuilder { // Create a GLSL450 call template - Value call_glsl450(const SType &ret_type, uint32_t inst_id, Args &&... args) { + Value call_glsl450(const SType &ret_type, uint32_t inst_id, Args &&...args) { Value val = new_value(ret_type, ValueKind::kNormal); ib_.begin(spv::OpExtInst) .add_seq(ret_type, val, ext_glsl450_, inst_id) diff --git a/taichi/common/serialization.h b/taichi/common/serialization.h index 251d72ea92834a..324a9e4916031d 100644 --- a/taichi/common/serialization.h +++ b/taichi/common/serialization.h @@ -112,7 +112,7 @@ typename std::enable_if::value, void>::type serialize_kv_impl(SER &ser, const std::array &keys, T &&head, - Args &&... rest) { + Args &&...rest) { constexpr auto i = (N - 1 - sizeof...(Args)); std::string key{keys[i]}; ser(key.c_str(), head); @@ -126,7 +126,7 @@ typename std::enable_if::value, void>::type serialize_kv_impl(SER &ser, const std::array &keys, T &&head, - Args &&... rest) { + Args &&...rest) { constexpr auto i = (N - 1 - sizeof...(Args)); std::string key{keys[i]}; ser(key.c_str(), head, true); diff --git a/taichi/ir/control_flow_graph.h b/taichi/ir/control_flow_graph.h index 1e98a4ce803d71..ecb0f38d22311f 100644 --- a/taichi/ir/control_flow_graph.h +++ b/taichi/ir/control_flow_graph.h @@ -99,7 +99,7 @@ class ControlFlowGraph { int final_node{0}; template - CFGNode *push_back(Args &&... args) { + CFGNode *push_back(Args &&...args) { nodes.emplace_back(std::make_unique(std::forward(args)...)); return nodes.back().get(); } diff --git a/taichi/ir/expr.h b/taichi/ir/expr.h index 1965492b985eeb..f5d2ba4db8acfd 100644 --- a/taichi/ir/expr.h +++ b/taichi/ir/expr.h @@ -86,7 +86,7 @@ class Expr { Expr operator!(); template - static Expr make(Args &&... args) { + static Expr make(Args &&...args) { return Expr(std::make_shared(std::forward(args)...)); } diff --git a/taichi/ir/expression.h b/taichi/ir/expression.h index 09ede3cbbbbd75..4b9616010048f2 100644 --- a/taichi/ir/expression.h +++ b/taichi/ir/expression.h @@ -26,7 +26,7 @@ class Expression { } template - T *push_back(Args &&... args) { + T *push_back(Args &&...args) { return stmts.push_back(std::forward(args)...); } diff --git a/taichi/ir/expression_printer.h b/taichi/ir/expression_printer.h index d76cbd8de286c9..2141d82facdcd2 100644 --- a/taichi/ir/expression_printer.h +++ b/taichi/ir/expression_printer.h @@ -226,7 +226,7 @@ class ExpressionHumanFriendlyPrinter : public ExpressionPrinter { protected: template - void emit(Args &&... args) { + void emit(Args &&...args) { (this->get_ostream() << ... << std::forward(args)); } diff --git a/taichi/ir/ir.h b/taichi/ir/ir.h index 0f89cd604a9580..6996af813a5414 100644 --- a/taichi/ir/ir.h +++ b/taichi/ir/ir.h @@ -130,7 +130,7 @@ class VecStatement { Stmt *push_back(pStmt &&stmt); template - T *push_back(Args &&... args) { + T *push_back(Args &&...args) { auto up = std::make_unique(std::forward(args)...); auto ptr = up.get(); stmts.push_back(std::move(up)); @@ -458,7 +458,7 @@ class StmtFieldManager { void operator()(const char *key, T &&value); template - void operator()(const char *key_, T &&t, Args &&... rest) { + void operator()(const char *key_, T &&t, Args &&...rest) { std::string key(key_); size_t pos = key.find(','); std::string first_name = key.substr(0, pos); @@ -572,12 +572,12 @@ class Stmt : public IRNode { } template - static std::unique_ptr make_typed(Args &&... args) { + static std::unique_ptr make_typed(Args &&...args) { return std::make_unique(std::forward(args)...); } template - static pStmt make(Args &&... args) { + static pStmt make(Args &&...args) { return make_typed(std::forward(args)...); } @@ -653,7 +653,7 @@ class Block : public IRNode { } template - Stmt *push_back(Args &&... args) { + Stmt *push_back(Args &&...args) { auto stmt = std::make_unique(std::forward(args)...); stmt->parent = this; statements.emplace_back(std::move(stmt)); diff --git a/taichi/ir/ir_builder.h b/taichi/ir/ir_builder.h index 049b09649c3d05..48fd37a078b9d4 100644 --- a/taichi/ir/ir_builder.h +++ b/taichi/ir/ir_builder.h @@ -213,7 +213,7 @@ class IRBuilder { // Print values and strings. Arguments can be Stmt* or std::string. template - PrintStmt *create_print(Args &&... args) { + PrintStmt *create_print(Args &&...args) { return insert(Stmt::make_typed(std::forward(args)...)); } diff --git a/taichi/ir/statements.h b/taichi/ir/statements.h index c651f2d592c666..83e9a57f49fd05 100644 --- a/taichi/ir/statements.h +++ b/taichi/ir/statements.h @@ -690,13 +690,13 @@ class PrintStmt : public Stmt { } template - PrintStmt(Stmt *t, Args &&... args) + PrintStmt(Stmt *t, Args &&...args) : contents(make_entries(t, std::forward(args)...)) { TI_STMT_REG_FIELDS; } template - PrintStmt(const std::string &str, Args &&... args) + PrintStmt(const std::string &str, Args &&...args) : contents(make_entries(str, std::forward(args)...)) { TI_STMT_REG_FIELDS; } @@ -711,13 +711,13 @@ class PrintStmt : public Stmt { template static void make_entries_helper(std::vector &entries, T &&t, - Args &&... values) { + Args &&...values) { entries.push_back(EntryType{t}); make_entries_helper(entries, std::forward(values)...); } template - static std::vector make_entries(Args &&... values) { + static std::vector make_entries(Args &&...values) { std::vector ret; make_entries_helper(ret, std::forward(values)...); return ret; diff --git a/taichi/jit/jit_module.h b/taichi/jit/jit_module.h index d78a4a1d744a70..035f3ad8c9a743 100644 --- a/taichi/jit/jit_module.h +++ b/taichi/jit/jit_module.h @@ -38,7 +38,7 @@ class JITModule { } template - static std::vector get_arg_pointers(T &t, Args &... args) { + static std::vector get_arg_pointers(T &t, Args &...args) { auto ret = get_arg_pointers(args...); ret.insert(ret.begin(), &t); return ret; diff --git a/taichi/llvm/llvm_codegen_utils.h b/taichi/llvm/llvm_codegen_utils.h index fcb941abde4f7d..17ae948854a005 100644 --- a/taichi/llvm/llvm_codegen_utils.h +++ b/taichi/llvm/llvm_codegen_utils.h @@ -113,7 +113,7 @@ class LLVMModuleBuilder { template llvm::Value *call(llvm::IRBuilder<> *builder, const std::string &func_name, - Args &&... args) { + Args &&...args) { auto func = get_runtime_function(func_name); auto arglist = std::vector({args...}); check_func_call_signature(func, arglist); @@ -121,7 +121,7 @@ class LLVMModuleBuilder { } template - llvm::Value *call(const std::string &func_name, Args &&... args) { + llvm::Value *call(const std::string &func_name, Args &&...args) { return call(this->builder.get(), func_name, std::forward(args)...); } @@ -183,7 +183,7 @@ class RuntimeObject { } template - llvm::Value *call(const std::string &func_name, Args &&... args) { + llvm::Value *call(const std::string &func_name, Args &&...args) { auto func = get_func(func_name); auto arglist = std::vector({ptr, args...}); check_func_call_signature(func, arglist); diff --git a/taichi/runtime/llvm/runtime.cpp b/taichi/runtime/llvm/runtime.cpp index ad6d4538bc52ba..162d312d867cc4 100644 --- a/taichi/runtime/llvm/runtime.cpp +++ b/taichi/runtime/llvm/runtime.cpp @@ -151,7 +151,7 @@ T ifloordiv(T a, T b) { struct LLVMRuntime; template -void taichi_printf(LLVMRuntime *runtime, const char *format, Args &&... args); +void taichi_printf(LLVMRuntime *runtime, const char *format, Args &&...args); extern "C" { @@ -594,7 +594,7 @@ struct LLVMRuntime { } template - T *create(Args &&... args) { + T *create(Args &&...args) { auto ptr = (T *)request_allocate_aligned(sizeof(T), 4096); new (ptr) T(std::forward(args)...); return ptr; @@ -1736,7 +1736,7 @@ struct printf_helper { } template - void push_back(T t, Args &&... args) { + void push_back(T t, Args &&...args) { *(T *)&buffer[tail] = t; if (tail % sizeof(T) != 0) tail += sizeof(T) - tail % sizeof(T); @@ -1753,7 +1753,7 @@ struct printf_helper { }; template -void taichi_printf(LLVMRuntime *runtime, const char *format, Args &&... args) { +void taichi_printf(LLVMRuntime *runtime, const char *format, Args &&...args) { #if ARCH_cuda printf_helper helper; helper.push_back(std::forward(args)...); diff --git a/taichi/transforms/auto_diff.cpp b/taichi/transforms/auto_diff.cpp index 82f65de408bbcd..b9b7d493648f45 100644 --- a/taichi/transforms/auto_diff.cpp +++ b/taichi/transforms/auto_diff.cpp @@ -600,7 +600,7 @@ class MakeAdjoint : public IRVisitor { } template - Stmt *insert(Args &&... args) { + Stmt *insert(Args &&...args) { return insert_back(Stmt::make(args...)); } diff --git a/taichi/transforms/ir_printer.cpp b/taichi/transforms/ir_printer.cpp index b52ce79e076518..69ce6c4195e719 100644 --- a/taichi/transforms/ir_printer.cpp +++ b/taichi/transforms/ir_printer.cpp @@ -61,7 +61,7 @@ class IRPrinter : public IRVisitor { } template - void print(std::string f, Args &&... args) { + void print(std::string f, Args &&...args) { print_raw(fmt::format(f, std::forward(args)...)); } diff --git a/taichi/transforms/make_thread_local.cpp b/taichi/transforms/make_thread_local.cpp index 54afb9b6870b31..68c082e8221729 100644 --- a/taichi/transforms/make_thread_local.cpp +++ b/taichi/transforms/make_thread_local.cpp @@ -143,11 +143,10 @@ void make_thread_local_offload(OffloadedStmt *offload) { TypeFactory::create_vector_or_scalar_type(1, data_type, true)); auto zero = offload->tls_prologue->insert( - std::make_unique(dest.second == AtomicOpType::max - ? get_min_value(data_type) - : dest.second == AtomicOpType::min - ? get_max_value(data_type) - : TypedConstant(data_type, 0)), + std::make_unique( + dest.second == AtomicOpType::max ? get_min_value(data_type) + : dest.second == AtomicOpType::min ? get_max_value(data_type) + : TypedConstant(data_type, 0)), -1); // Zero-fill // TODO: do not use GlobalStore for TLS ptr. diff --git a/taichi/util/line_appender.h b/taichi/util/line_appender.h index f8cdfe78fb34ba..026969a4df4a24 100644 --- a/taichi/util/line_appender.h +++ b/taichi/util/line_appender.h @@ -23,7 +23,7 @@ class LineAppender { } template - void append(std::string f, Args &&... args) { + void append(std::string f, Args &&...args) { lines_ += indent_ + fmt::format(f, std::forward(args)...) + '\n'; } diff --git a/taichi/util/meta.h b/taichi/util/meta.h index 306c373764db87..3db5bd3bfff7fe 100644 --- a/taichi/util/meta.h +++ b/taichi/util/meta.h @@ -17,7 +17,7 @@ namespace taichi { namespace meta { template