Skip to content

Commit

Permalink
fix: type annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
topaxi committed Feb 9, 2024
1 parent a466e53 commit 4e19683
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 11 deletions.
9 changes: 4 additions & 5 deletions lua/gh-actions/github.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 {}

Expand Down Expand Up @@ -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 {}

Expand Down Expand Up @@ -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 {}

Expand All @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions lua/gh-actions/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ end

local function now()
local date = os.date('!*t')
---@cast date osdate
---@cast date osdateparam
return os.time(date)
end

Expand All @@ -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] = {
Expand Down
1 change: 1 addition & 0 deletions lua/gh-actions/ui.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
Expand Down
4 changes: 2 additions & 2 deletions lua/gh-actions/ui/render.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down
2 changes: 1 addition & 1 deletion lua/gh-actions/utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 4e19683

Please sign in to comment.