Skip to content

Use staticmethod for get_type_from_code - #4693

Merged
svartkanin merged 1 commit into
archlinux:masterfrom
codefiles:pt-get-type-from-code
Aug 3, 2026
Merged

Use staticmethod for get_type_from_code#4693
svartkanin merged 1 commit into
archlinux:masterfrom
codefiles:pt-get-type-from-code

Conversation

@codefiles

Copy link
Copy Markdown
Contributor

Addresses the following:

pyright

  archinstall/lib/models/device.py:759:11 - error: Type "Literal[PartitionType.PRIMARY]" is not assignable to return type "Self@PartitionType"
    Type "Literal[PartitionType.PRIMARY]" is not assignable to type "Self@PartitionType" (reportReturnType)
  archinstall/lib/models/device.py:762:11 - error: Type "Literal[PartitionType._UNKNOWN]" is not assignable to return type "Self@PartitionType"
    Type "Literal[PartitionType._UNKNOWN]" is not assignable to type "Self@PartitionType" (reportReturnType)

pyrefly

ERROR Returned type `Literal[PartitionType.PRIMARY]` is not assignable to declared return type `Self@PartitionType` [bad-return]
   --> archinstall/lib/models/device.py:759:11
    |
757 |     def get_type_from_code(cls, code: int) -> Self:
    |                                               ---- declared return type
758 |         if code == parted.PARTITION_NORMAL:
759 |             return cls.PRIMARY
    |                    ^^^^^^^^^^^
    |
ERROR Returned type `Literal[PartitionType._UNKNOWN]` is not assignable to declared return type `Self@PartitionType` [bad-return]
   --> archinstall/lib/models/device.py:762:11
    |
757 |     def get_type_from_code(cls, code: int) -> Self:
    |                                               ---- declared return type
758 |         if code == parted.PARTITION_NORMAL:
759 |             return cls.PRIMARY
760 |         else:
761 |             debug(f'Partition code not supported: {code}')
762 |             return cls._UNKNOWN
    |                    ^^^^^^^^^^^^
    |

ty

error[invalid-return-type]: Return type does not match returned value
   --> archinstall/lib/models/device.py:757:44
    |
757 |     def get_type_from_code(cls, code: int) -> Self:
    |                                               ---- Expected `Self@get_type_from_code` because of return type
758 |         if code == parted.PARTITION_NORMAL:
759 |             return cls.PRIMARY
    |                    ^^^^^^^^^^^ expected `Self@get_type_from_code`, found `Literal[PartitionType.PRIMARY]`
    |

error[invalid-return-type]: Return type does not match returned value
   --> archinstall/lib/models/device.py:757:44
    |
757 |     def get_type_from_code(cls, code: int) -> Self:
    |                                               ---- Expected `Self@get_type_from_code` because of return type
758 |         if code == parted.PARTITION_NORMAL:
759 |             return cls.PRIMARY
760 |         else:
761 |             debug(f'Partition code not supported: {code}')
762 |             return cls._UNKNOWN
    |                    ^^^^^^^^^^^^ expected `Self@get_type_from_code`, found `Literal[PartitionType._UNKNOWN]`
    |

Addresses the following:

pyright

```
  archinstall/lib/models/device.py:759:11 - error: Type "Literal[PartitionType.PRIMARY]" is not assignable to return type "Self@PartitionType"
    Type "Literal[PartitionType.PRIMARY]" is not assignable to type "Self@PartitionType" (reportReturnType)
  archinstall/lib/models/device.py:762:11 - error: Type "Literal[PartitionType._UNKNOWN]" is not assignable to return type "Self@PartitionType"
    Type "Literal[PartitionType._UNKNOWN]" is not assignable to type "Self@PartitionType" (reportReturnType)
```

pyrefly

```
ERROR Returned type `Literal[PartitionType.PRIMARY]` is not assignable to declared return type `Self@PartitionType` [bad-return]
   --> archinstall/lib/models/device.py:759:11
    |
757 |     def get_type_from_code(cls, code: int) -> Self:
    |                                               ---- declared return type
758 |         if code == parted.PARTITION_NORMAL:
759 |             return cls.PRIMARY
    |                    ^^^^^^^^^^^
    |
ERROR Returned type `Literal[PartitionType._UNKNOWN]` is not assignable to declared return type `Self@PartitionType` [bad-return]
   --> archinstall/lib/models/device.py:762:11
    |
757 |     def get_type_from_code(cls, code: int) -> Self:
    |                                               ---- declared return type
758 |         if code == parted.PARTITION_NORMAL:
759 |             return cls.PRIMARY
760 |         else:
761 |             debug(f'Partition code not supported: {code}')
762 |             return cls._UNKNOWN
    |                    ^^^^^^^^^^^^
    |
```

ty

```
error[invalid-return-type]: Return type does not match returned value
   --> archinstall/lib/models/device.py:757:44
    |
757 |     def get_type_from_code(cls, code: int) -> Self:
    |                                               ---- Expected `Self@get_type_from_code` because of return type
758 |         if code == parted.PARTITION_NORMAL:
759 |             return cls.PRIMARY
    |                    ^^^^^^^^^^^ expected `Self@get_type_from_code`, found `Literal[PartitionType.PRIMARY]`
    |

error[invalid-return-type]: Return type does not match returned value
   --> archinstall/lib/models/device.py:757:44
    |
757 |     def get_type_from_code(cls, code: int) -> Self:
    |                                               ---- Expected `Self@get_type_from_code` because of return type
758 |         if code == parted.PARTITION_NORMAL:
759 |             return cls.PRIMARY
760 |         else:
761 |             debug(f'Partition code not supported: {code}')
762 |             return cls._UNKNOWN
    |                    ^^^^^^^^^^^^ expected `Self@get_type_from_code`, found `Literal[PartitionType._UNKNOWN]`
    |
```
@codefiles
codefiles requested a review from Torxed as a code owner August 3, 2026 12:50
@svartkanin
svartkanin merged commit 9a19e39 into archlinux:master Aug 3, 2026
11 checks passed
@codefiles
codefiles deleted the pt-get-type-from-code branch August 4, 2026 00:09
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.

2 participants