From 4e19683aa581d8670d99e74104610a673f11964d Mon Sep 17 00:00:00 2001 From: Damian Senn Date: Fri, 9 Feb 2024 12:03:38 +0100 Subject: [PATCH] fix: type annotations --- lua/gh-actions/github.lua | 9 ++++----- lua/gh-actions/init.lua | 6 +++--- lua/gh-actions/ui.lua | 1 + lua/gh-actions/ui/render.lua | 4 ++-- lua/gh-actions/utils.lua | 2 +- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/lua/gh-actions/github.lua b/lua/gh-actions/github.lua index d238da9..07f20e0 100644 --- a/lua/gh-actions/github.lua +++ b/lua/gh-actions/github.lua @@ -46,7 +46,7 @@ local function get_token_from_gh_cli(cmd) res = vim.fn.system('gh auth token') end - local token = string.gsub(res, '\n', '') + local token = string.gsub(res or '', '\n', '') if token == '' then return nil @@ -97,7 +97,7 @@ end ---@field workflows GhWorkflow[] ---@param repo string ----@param opts? table +---@param opts? { callback?: fun(workflows: GhWorkflow[]): any } function M.get_workflows(repo, opts) opts = opts or {} @@ -183,7 +183,7 @@ end ---@param repo string ---@param workflow_id integer ---@param per_page? integer ----@param opts? table +---@param opts? { callback?: fun(workflow_runs: GhWorkflowRun[]): any } function M.get_workflow_runs(repo, workflow_id, per_page, opts) opts = opts or {} @@ -240,7 +240,7 @@ end ---@param repo string ---@param workflow_run_id integer ---@param per_page? integer ----@param opts? { callback?: fun(workflow_runs: GhWorkflowRun[]): any } +---@param opts? { callback?: fun(workflow_runs: GhWorkflowRunJob[]): any } function M.get_workflow_run_jobs(repo, workflow_run_id, per_page, opts) opts = opts or {} @@ -267,7 +267,6 @@ function M.get_workflow_run_jobs(repo, workflow_run_id, per_page, opts) ) end ----TODO lua-yaml is not able to fully parse most yaml files.. ---@param path string ---@return table function M.get_workflow_config(path) diff --git a/lua/gh-actions/init.lua b/lua/gh-actions/init.lua index 30893e2..c0c7514 100644 --- a/lua/gh-actions/init.lua +++ b/lua/gh-actions/init.lua @@ -82,7 +82,7 @@ end local function now() local date = os.date('!*t') - ---@cast date osdate + ---@cast date osdateparam return os.time(date) end @@ -95,8 +95,8 @@ function M.update_workflow_configs(state) for _, workflow in ipairs(state.workflows) do if - not state.workflow_configs[workflow.id] - or (n - state.workflow_configs[workflow.id].last_read) + not state.workflow_configs[workflow.id] + or (n - state.workflow_configs[workflow.id].last_read) > WORKFLOW_CONFIG_CACHE_TTL_S then state.workflow_configs[workflow.id] = { diff --git a/lua/gh-actions/ui.lua b/lua/gh-actions/ui.lua index d09f7ad..55936d1 100644 --- a/lua/gh-actions/ui.lua +++ b/lua/gh-actions/ui.lua @@ -4,6 +4,7 @@ local store = require('gh-actions.store') local Render = require('gh-actions.ui.render') local M = { + ---@type NuiSplit split = nil, renderer = nil, } diff --git a/lua/gh-actions/ui/render.lua b/lua/gh-actions/ui/render.lua index af56fa4..c5865cd 100644 --- a/lua/gh-actions/ui/render.lua +++ b/lua/gh-actions/ui/render.lua @@ -7,8 +7,8 @@ local utils = require('gh-actions.utils') ---@class GhActionsRenderLocation ---@field value any ---@field kind string ----@field from integer ----@field to integer +---@field from? integer +---@field to? integer ---@class GhActionsRender:Buffer ---@field store { get_state: fun(): GhActionsState } diff --git a/lua/gh-actions/utils.lua b/lua/gh-actions/utils.lua index 21f9d0b..8838f55 100644 --- a/lua/gh-actions/utils.lua +++ b/lua/gh-actions/utils.lua @@ -57,7 +57,7 @@ function M.parse_yaml(yamlstr) if has_rust_module then return rust.parse_yaml(yamlstr or '') else - return vim.json.decode(vim.fn.system('yq', yamlstr)) + return vim.json.decode(vim.fn.system('yq', yamlstr) or '') end end