From c78aa8495462a27c2ae975abc716c3c631274971 Mon Sep 17 00:00:00 2001 From: Nsukami Patrick Date: Fri, 9 Jul 2021 00:50:13 +0000 Subject: [PATCH 1/5] Update pwd stub file Add the following properties to struct_passwd: * n_fields * n_sequence_fields * n_unnamed_fields To fix the following errors: * pwd.struct_passwd.n_fields is not present in stub * pwd.struct_passwd.n_sequence_fields is not present in stub * pwd.struct_passwd.n_unnamed_fields is not present in stub --- stdlib/pwd.pyi | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/stdlib/pwd.pyi b/stdlib/pwd.pyi index 83020c1576dd..5b1ab2674df6 100644 --- a/stdlib/pwd.pyi +++ b/stdlib/pwd.pyi @@ -9,6 +9,13 @@ class struct_passwd(Tuple[str, str, int, int, str, str, str]): pw_dir: str pw_shell: str + @property + def n_fields(self) -> int: ... + @property + def n_sequence_fields(self) -> int: ... + @property + def n_unnamed_fields(self) -> int: ... + def getpwall() -> List[struct_passwd]: ... def getpwuid(__uid: int) -> struct_passwd: ... def getpwnam(__name: str) -> struct_passwd: ... From 29cca48fa7c386d8f5f345a5ca417bba963f9a51 Mon Sep 17 00:00:00 2001 From: Nsukami Patrick Date: Fri, 9 Jul 2021 06:18:26 +0000 Subject: [PATCH 2/5] Format without any compromise --- stdlib/pwd.pyi | 1 - 1 file changed, 1 deletion(-) diff --git a/stdlib/pwd.pyi b/stdlib/pwd.pyi index 5b1ab2674df6..acb7d1c8d263 100644 --- a/stdlib/pwd.pyi +++ b/stdlib/pwd.pyi @@ -8,7 +8,6 @@ class struct_passwd(Tuple[str, str, int, int, str, str, str]): pw_gecos: str pw_dir: str pw_shell: str - @property def n_fields(self) -> int: ... @property From 7eb73f128c5d4460e55d113e05db528d3f35c3ee Mon Sep 17 00:00:00 2001 From: Nsukami Patrick Date: Fri, 9 Jul 2021 09:19:59 +0000 Subject: [PATCH 3/5] Add properties as class attributes instead of methods --- stdlib/pwd.pyi | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/stdlib/pwd.pyi b/stdlib/pwd.pyi index acb7d1c8d263..78d305a98eff 100644 --- a/stdlib/pwd.pyi +++ b/stdlib/pwd.pyi @@ -8,12 +8,10 @@ class struct_passwd(Tuple[str, str, int, int, str, str, str]): pw_gecos: str pw_dir: str pw_shell: str - @property - def n_fields(self) -> int: ... - @property - def n_sequence_fields(self) -> int: ... - @property - def n_unnamed_fields(self) -> int: ... + + n_fields: int + n_sequence_fields: int + n_unnamed_fields: int def getpwall() -> List[struct_passwd]: ... def getpwuid(__uid: int) -> struct_passwd: ... From 70b209483a4d909361b96d79d275cd7e5d840ffb Mon Sep 17 00:00:00 2001 From: Nsukami Patrick Date: Fri, 9 Jul 2021 09:25:26 +0000 Subject: [PATCH 4/5] Improve type signature for n_fields, n_sequence_fields & n_unnamed_fields properties Those properties are not simple integers, they are also class variables. --- stdlib/pwd.pyi | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/stdlib/pwd.pyi b/stdlib/pwd.pyi index 78d305a98eff..9597dda1f295 100644 --- a/stdlib/pwd.pyi +++ b/stdlib/pwd.pyi @@ -1,4 +1,4 @@ -from typing import List, Tuple +from typing import List, Tuple, ClassVar class struct_passwd(Tuple[str, str, int, int, str, str, str]): pw_name: str @@ -9,9 +9,9 @@ class struct_passwd(Tuple[str, str, int, int, str, str, str]): pw_dir: str pw_shell: str - n_fields: int - n_sequence_fields: int - n_unnamed_fields: int + n_fields: ClassVar[int] + n_sequence_fields: ClassVar[int] + n_unnamed_fields: ClassVar[int] def getpwall() -> List[struct_passwd]: ... def getpwuid(__uid: int) -> struct_passwd: ... From 3c809d458644e222da2f7a2a122863191197daa3 Mon Sep 17 00:00:00 2001 From: Nsukami Patrick Date: Fri, 9 Jul 2021 09:39:48 +0000 Subject: [PATCH 5/5] Sort pwd.pyi imports --- stdlib/pwd.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stdlib/pwd.pyi b/stdlib/pwd.pyi index 9597dda1f295..3585cc235a58 100644 --- a/stdlib/pwd.pyi +++ b/stdlib/pwd.pyi @@ -1,4 +1,4 @@ -from typing import List, Tuple, ClassVar +from typing import ClassVar, List, Tuple class struct_passwd(Tuple[str, str, int, int, str, str, str]): pw_name: str