Skip to content

Bring EmmyLua annotations - #68

Merged
patapenka-alexey merged 10 commits into
masterfrom
ligurio/gh-xxxx-emmylua-annotations
Aug 18, 2026
Merged

Bring EmmyLua annotations#68
patapenka-alexey merged 10 commits into
masterfrom
ligurio/gh-xxxx-emmylua-annotations

Conversation

@ligurio

@ligurio ligurio commented Aug 7, 2026

Copy link
Copy Markdown
Member

@ligurio
ligurio force-pushed the ligurio/gh-xxxx-emmylua-annotations branch 2 times, most recently from c11d82a to 35ed1d9 Compare August 7, 2026 14:59
ligurio added 10 commits August 13, 2026 21:53
The patch updates luacheckrc to suppress warnings.
Follows up the commit 49fa005
("test: add linting stage").
The patch adds comments for functions with descriptions
and argument types in EmmyLua format.

Needed for tarantool/tarantool#13020
The patch introduces an initial configuration file .emmyrc for
emmylua_check, it is a modern static analuzer for Lua.
The configuration file has the same excluded directories as in
.luacheckrc and config disables a number of rules. Most of them
will be enabled back in the following commits except the following
rules:
- "unresolved-require" (7 warnings) is disabled because most modules
  are Tarantool builtins: `json`, `log`, `uuid`; no source code is
  included in the project.
- "need-check-nil" (22 warnings) is disabled because these
  warnings are not critical and I don't want to add extra checks
  to the code.
- "redefined-local" is disabled because it was disabled for
  luacheck in the commit 49fa005
  ("test: add linting stage").
The patch rule `assign-type-mismatch` in the .emmyrc and fixes
three warnings:

- @Class checks moved to the module table - no longer sticks to
  local ffi.
- `checks(...)`: vararg typed as `checks.qualifier|number`, level
  annotated with ---@type number, stack level retrieved via
  narrowed local first.
- @field checks field consistent with type
  `fun(...: checks.qualifier|number)`.
The patch enables rule `call-non-callable` and fixes warnings
produced by this rule: removed class checks/@field from the modul
table, now the `require('checks')` type is inferred from
setmetatable (callable via variadic `__call`, checks/_VERSION
fields are referenced). Field documentation has been moved to the
module header.
The patch enables rule `duplicate-require` in the .emmyrc
and removes duplicate require for `ffi` module.
The patch enables rule `param-type-mismatch` in the .emmyrc
and fixes 20 warnings produced by this rule.
The patch enables rule `undefined-field` in the .emmyrc and fixes
errors produced by this rule. The error is in using `table.deepcopy()`
in test/test.lua because Tarantool API is unknown to the analyzer.
The patch created a definition for `table.deepcopy()` in a file
test/types.lua.
The patch enables `unnecessary-if` in the .emmyrc and fixes
a warning produced by this rule. The reason of warning is an
unknown type of variable `qualifier`. The analyzer infers the
`optional` field as literal `false` and doesn't track the assignment
`qualifier.optional = true` inside the `gmatch` loop, so
`unnecessary-if` considers the condition is always `false`. This
is a false positive - at runtime, the condition is reachable
(e.g., '?string').

The patch adds the annotation to the local variable `qualifier` -
the `optional` field is now typed as boolean, and the analyzer
no longer considers the condition to always be false.
The patch enables rule `unused` and fixes a warnings produced by
this rule by adding an underscore to the prefix of variables that
are not used.
@patapenka-alexey

Copy link
Copy Markdown
Contributor

I see old commits. Could you please rebase your branch relative to master?

@patapenka-alexey
patapenka-alexey self-requested a review August 14, 2026 06:38
@patapenka-alexey
patapenka-alexey force-pushed the ligurio/gh-xxxx-emmylua-annotations branch from 35ed1d9 to 507b1b7 Compare August 17, 2026 08:48
@patapenka-alexey
patapenka-alexey requested review from bigbes, elhimov and oleg-jukovec and removed request for oleg-jukovec August 17, 2026 08:49
@patapenka-alexey
patapenka-alexey merged commit 85d145f into master Aug 18, 2026
6 checks passed
@patapenka-alexey
patapenka-alexey deleted the ligurio/gh-xxxx-emmylua-annotations branch August 18, 2026 19:22
@patapenka-alexey patapenka-alexey mentioned this pull request Aug 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants