On Mon, Mar 18, 2024 at 01:26:18AM -0000, Alex Murray wrote:
> scripts/check-cves: fix a bunch of pyright warnings
>
> Before:
>
> ± pyright scripts/check-cves
> /home/amurray/ubuntu/git/ubuntu-cve-tracker/scripts/check-cves
> /home/amurray/ubuntu/git/ubuntu-cve-tracker/scripts/check-cves:211:32 - error: Object of type "str" is not callable (reportCallIssue)
> /home/amurray/ubuntu/git/ubuntu-cve-tracker/scripts/check-cves:252:37 - error: Operator "+" not supported for types "str | Unknown | list[str | Unknown] | list[Unknown]" and "Literal['/data/DSA/list']"
> Operator "+" not supported for types "list[str | Unknown]" and "Literal['/data/DSA/list']"
> Operator "+" not supported for types "list[Unknown]" and "Literal['/data/DSA/list']" (reportOperatorIssue)
> /home/amurray/ubuntu/git/ubuntu-cve-tracker/scripts/check-cves:326:32 - error: Argument of type "(cve: Unknown) -> Unknown" cannot be assigned to parameter "desc" of type "str" in function "convert_to_nvd"
> "function" is incompatible with "str" (reportArgumentType)
> /home/amurray/ubuntu/git/ubuntu-cve-tracker/scripts/check-cves:414:32 - error: Argument of type "(cve: Unknown) -> Unknown" cannot be assigned to parameter "desc" of type "str" in function "convert_to_nvd"
> "function" is incompatible with "str" (reportArgumentType)
> /home/amurray/ubuntu/git/ubuntu-cve-tracker/scripts/check-cves:497:32 - error: Argument of type "(c: Unknown) -> str" cannot be assigned to parameter "desc" of type "str" in function "convert_to_nvd"
> "function" is incompatible with "str" (reportArgumentType)
> /home/amurray/ubuntu/git/ubuntu-cve-tracker/scripts/check-cves:597:52 - error: Operator "+" not supported for types "str | Unknown | list[str | Unknown] | list[Unknown]" and "Literal['/data/CVE/list']"
> Operator "+" not supported for types "list[str | Unknown]" and "Literal['/data/CVE/list']"
> Operator "+" not supported for types "list[Unknown]" and "Literal['/data/CVE/list']" (reportOperatorIssue)
> /home/amurray/ubuntu/git/ubuntu-cve-tracker/scripts/check-cves:780:49 - error: Operator "not in" not supported for types "Literal['Previously triaged as ignored in Ubuntu\n\n']" and "str | None"
> Operator "not in" not supported for types "Literal['Previously triaged as ignored in Ubuntu\n\n']" and "None" (reportOperatorIssue)
> /home/amurray/ubuntu/git/ubuntu-cve-tracker/scripts/check-cves:786:30 - error: "split" is not a known member of "None" (reportOptionalMemberAccess)
> /home/amurray/ubuntu/git/ubuntu-cve-tracker/scripts/check-cves:791:27 - error: "find" is not a known member of "None" (reportOptionalMemberAccess)
> /home/amurray/ubuntu/git/ubuntu-cve-tracker/scripts/check-cves:791:59 - error: "find" is not a known member of "None" (reportOptionalMemberAccess)
> /home/amurray/ubuntu/git/ubuntu-cve-tracker/scripts/check-cves:1474:20 - error: "_exceptions" is not a known member of module "xml.sax" (reportAttributeAccessIssue)
> /home/amurray/ubuntu/git/ubuntu-cve-tracker/scripts/check-cves:1622:39 - error: Argument of type "_TemporaryFileWrapper[str] | TextIO" cannot be assigned to parameter "file" of type "TextIO" in function "display_cve"
> Type "_TemporaryFileWrapper[str] | TextIO" cannot be assigned to type "TextIO"
> "_TemporaryFileWrapper[str]" is incompatible with "TextIO" (reportArgumentType)
> /home/amurray/ubuntu/git/ubuntu-cve-tracker/scripts/check-cves:1631:39 - error: Argument of type "_TemporaryFileWrapper[str] | TextIO" cannot be assigned to parameter "file" of type "TextIO" in function "display_cve"
> Type "_TemporaryFileWrapper[str] | TextIO" cannot be assigned to type "TextIO"
> "_TemporaryFileWrapper[str]" is incompatible with "TextIO" (reportArgumentType)
> 13 errors, 0 warnings, 0 informations
>
> After:
>
> ± pyright scripts/check-cves
> /home/amurray/ubuntu/git/ubuntu-cve-tracker/scripts/check-cves
> /home/amurray/ubuntu/git/ubuntu-cve-tracker/scripts/check-cves:253:37 - error: Operator "+" not supported for types "str | Unknown | list[str | Unknown] | list[Unknown]" and "Literal['/data/DSA/list']"
> Operator "+" not supported for types "list[str | Unknown]" and "Literal['/data/DSA/list']"
> Operator "+" not supported for types "list[Unknown]" and "Literal['/data/DSA/list']" (reportOperatorIssue)
> /home/amurray/ubuntu/git/ubuntu-cve-tracker/scripts/check-cves:598:52 - error: Operator "+" not supported for types "str | Unknown | list[str | Unknown] | list[Unknown]" and "Literal['/data/CVE/list']"
> Operator "+" not supported for types "list[str | Unknown]" and "Literal['/data/CVE/list']"
> Operator "+" not supported for types "list[Unknown]" and "Literal['/data/CVE/list']" (reportOperatorIssue)
> 2 errors, 0 warnings, 0 informations
>
> Signed-off-by: Alex Murray <email address hidden>
Thanks for including the pyright output to explain what's going on,
though I suspect some of these are pycodestyle fixups. But adding more
typing information would be good.
While the type hint is appreciated, that the argument named desc
is expected to be a function and not a string is a surprise to me,
and feels like it should be renamed or at the very least have an
explanatory comment. But that's not a blocker for landing this branch.
review approve
On Mon, Mar 18, 2024 at 01:26:18AM -0000, Alex Murray wrote: ubuntu/ git/ubuntu- cve-tracker/ scripts/ check-cves ubuntu/ git/ubuntu- cve-tracker/ scripts/ check-cves: 211:32 - error: Object of type "str" is not callable (reportCallIssue) ubuntu/ git/ubuntu- cve-tracker/ scripts/ check-cves: 252:37 - error: Operator "+" not supported for types "str | Unknown | list[str | Unknown] | list[Unknown]" and "Literal[ '/data/ DSA/list' ]" '/data/ DSA/list' ]" '/data/ DSA/list' ]" (reportOperator Issue) ubuntu/ git/ubuntu- cve-tracker/ scripts/ check-cves: 326:32 - error: Argument of type "(cve: Unknown) -> Unknown" cannot be assigned to parameter "desc" of type "str" in function "convert_to_nvd" Type) ubuntu/ git/ubuntu- cve-tracker/ scripts/ check-cves: 414:32 - error: Argument of type "(cve: Unknown) -> Unknown" cannot be assigned to parameter "desc" of type "str" in function "convert_to_nvd" Type) ubuntu/ git/ubuntu- cve-tracker/ scripts/ check-cves: 497:32 - error: Argument of type "(c: Unknown) -> str" cannot be assigned to parameter "desc" of type "str" in function "convert_to_nvd" Type) ubuntu/ git/ubuntu- cve-tracker/ scripts/ check-cves: 597:52 - error: Operator "+" not supported for types "str | Unknown | list[str | Unknown] | list[Unknown]" and "Literal[ '/data/ CVE/list' ]" '/data/ CVE/list' ]" '/data/ CVE/list' ]" (reportOperator Issue) ubuntu/ git/ubuntu- cve-tracker/ scripts/ check-cves: 780:49 - error: Operator "not in" not supported for types "Literal[ 'Previously triaged as ignored in Ubuntu\n\n']" and "str | None" 'Previously triaged as ignored in Ubuntu\n\n']" and "None" (reportOperator Issue) ubuntu/ git/ubuntu- cve-tracker/ scripts/ check-cves: 786:30 - error: "split" is not a known member of "None" (reportOptional MemberAccess) ubuntu/ git/ubuntu- cve-tracker/ scripts/ check-cves: 791:27 - error: "find" is not a known member of "None" (reportOptional MemberAccess) ubuntu/ git/ubuntu- cve-tracker/ scripts/ check-cves: 791:59 - error: "find" is not a known member of "None" (reportOptional MemberAccess) ubuntu/ git/ubuntu- cve-tracker/ scripts/ check-cves: 1474:20 - error: "_exceptions" is not a known member of module "xml.sax" (reportAttribut eAccessIssue) ubuntu/ git/ubuntu- cve-tracker/ scripts/ check-cves: 1622:39 - error: Argument of type "_TemporaryFile Wrapper[ str] | TextIO" cannot be assigned to parameter "file" of type "TextIO" in function "display_cve" Wrapper[ str] | TextIO" cannot be assigned to type "TextIO" Wrapper[ str]" is incompatible with "TextIO" (reportArgument Type) ubuntu/ git/ubuntu- cve-tracker/ scripts/ check-cves: 1631:39 - error: Argument of type "_TemporaryFile Wrapper[ str] | TextIO" cannot be assigned to parameter "file" of type "TextIO" in function "display_cve" Wrapper[ str] | TextIO" cannot be assigned to type "TextIO" Wrapper[ str]" is incompatible with "TextIO" (reportArgument Type) ubuntu/ git/ubuntu- cve-tracker/ scripts/ check-cves ubuntu/ git/ubuntu- cve-tracker/ scripts/ check-cves: 253:37 - error: Operator "+" not supported for types "str | Unknown | list[str | Unknown] | list[Unknown]" and "Literal[ '/data/ DSA/list' ]" '/data/ DSA/list' ]" '/data/ DSA/list' ]" (reportOperator Issue) ubuntu/ git/ubuntu- cve-tracker/ scripts/ check-cves: 598:52 - error: Operator "+" not supported for types "str | Unknown | list[str | Unknown] | list[Unknown]" and "Literal[ '/data/ CVE/list' ]" '/data/ CVE/list' ]" '/data/ CVE/list' ]" (reportOperator Issue)
> scripts/check-cves: fix a bunch of pyright warnings
>
> Before:
>
> ± pyright scripts/check-cves
> /home/amurray/
> /home/amurray/
> /home/amurray/
> Operator "+" not supported for types "list[str | Unknown]" and "Literal[
> Operator "+" not supported for types "list[Unknown]" and "Literal[
> /home/amurray/
> "function" is incompatible with "str" (reportArgument
> /home/amurray/
> "function" is incompatible with "str" (reportArgument
> /home/amurray/
> "function" is incompatible with "str" (reportArgument
> /home/amurray/
> Operator "+" not supported for types "list[str | Unknown]" and "Literal[
> Operator "+" not supported for types "list[Unknown]" and "Literal[
> /home/amurray/
> Operator "not in" not supported for types "Literal[
> /home/amurray/
> /home/amurray/
> /home/amurray/
> /home/amurray/
> /home/amurray/
> Type "_TemporaryFile
> "_TemporaryFile
> /home/amurray/
> Type "_TemporaryFile
> "_TemporaryFile
> 13 errors, 0 warnings, 0 informations
>
> After:
>
> ± pyright scripts/check-cves
> /home/amurray/
> /home/amurray/
> Operator "+" not supported for types "list[str | Unknown]" and "Literal[
> Operator "+" not supported for types "list[Unknown]" and "Literal[
> /home/amurray/
> Operator "+" not supported for types "list[str | Unknown]" and "Literal[
> Operator "+" not supported for types "list[Unknown]" and "Literal[
> 2 errors, 0 warnings, 0 informations
>
> Signed-off-by: Alex Murray <email address hidden>
Thanks for including the pyright output to explain what's going on,
though I suspect some of these are pycodestyle fixups. But adding more
typing information would be good.
> diff --git a/scripts/ check-cves b/scripts/ check-cves check-cves check-cves object) : to_nvd( cves=[] , desc=""): to_nvd( cves=[] , desc=lambda _: ""):
> index e5cf20f..940d2d1 100755
> --- a/scripts/
> +++ b/scripts/
> @@ -183,7 +184,7 @@ class PercentageFile(
> return self.f.close()
>
>
> -def convert_
> +def convert_
While the type hint is appreciated, that the argument named desc
is expected to be a function and not a string is a surprise to me,
and feels like it should be renamed or at the very least have an
explanatory comment. But that's not a blocker for landing this branch.
--
Steve Beattie
<email address hidden>