diff --git a/.github/workflows/pyright.yaml b/.github/workflows/pyright.yaml new file mode 100644 index 0000000000..a717559ec5 --- /dev/null +++ b/.github/workflows/pyright.yaml @@ -0,0 +1,24 @@ +on: [ push, pull_request ] +name: Pyright type checking +jobs: + pyright: + runs-on: ubuntu-latest + container: + image: archlinux/archlinux:latest + steps: + - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5 + - name: Prepare arch + run: | + pacman-key --init + pacman --noconfirm -Sy archlinux-keyring + pacman --noconfirm -Syyu + pacman --noconfirm -Sy python-pip python-pyparted pkgconfig gcc nodejs npm + - run: pip install --break-system-packages --upgrade pip + - name: Install Python dependencies + run: pip install --break-system-packages .[dev] + - name: Install Node.js dependencies + run: npm install + - name: Display Pyright version + run: npx --no -- pyright --version + - name: Run Pyright + run: npx --no -- pyright diff --git a/.gitignore b/.gitignore index 9e30144f3b..376bdbd535 100644 --- a/.gitignore +++ b/.gitignore @@ -39,4 +39,5 @@ requirements.txt /.gitconfig /actions-runner /cmd_output.txt +node_modules/ uv.lock diff --git a/archinstall/lib/models/device.py b/archinstall/lib/models/device.py index 7dc940392e..fb056d0db6 100644 --- a/archinstall/lib/models/device.py +++ b/archinstall/lib/models/device.py @@ -317,10 +317,6 @@ class Size: unit: Unit sector_size: SectorSize - def __post_init__(self) -> None: - if not isinstance(self.sector_size, SectorSize): - raise ValueError('sector size must be of type SectorSize') - def json(self) -> _SizeSerialization: return { 'value': self.value, @@ -352,7 +348,9 @@ def convert( norm = self._normalize() return Size(norm, Unit.B, self.sector_size).convert(target_unit, sector_size) else: - if target_unit == Unit.sectors and sector_size is not None: + if target_unit == Unit.sectors: + assert sector_size is not None + norm = self._normalize() sectors = math.ceil(norm / sector_size.value) return Size(sectors, Unit.sectors, sector_size) diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000000..23122e3f35 --- /dev/null +++ b/package-lock.json @@ -0,0 +1,44 @@ +{ + "name": "archinstall", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "devDependencies": { + "pyright": "1.1.405" + } + }, + "node_modules/fsevents": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", + "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==", + "dev": true, + "hasInstallScript": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^8.16.0 || ^10.6.0 || >=11.0.0" + } + }, + "node_modules/pyright": { + "version": "1.1.405", + "resolved": "https://registry.npmjs.org/pyright/-/pyright-1.1.405.tgz", + "integrity": "sha512-hgy12kLZ1oAMtl9LTsByHftg3AD6Pouwu5rBsQlqYQqCCdGBgaQm9XDAPDap7ayWe9W+NWrUwO7Zy1K7uXoE2A==", + "dev": true, + "license": "MIT", + "bin": { + "pyright": "index.js", + "pyright-langserver": "langserver.index.js" + }, + "engines": { + "node": ">=14.0.0" + }, + "optionalDependencies": { + "fsevents": "~2.3.3" + } + } + } +} diff --git a/package.json b/package.json new file mode 100644 index 0000000000..5b45d5b650 --- /dev/null +++ b/package.json @@ -0,0 +1,5 @@ +{ + "devDependencies": { + "pyright": "1.1.405" + } +} diff --git a/pyproject.toml b/pyproject.toml index 40e6a3cb92..dc8d45f977 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -136,6 +136,7 @@ testpaths = ["tests"] ignore-paths = [ "^build/", "^docs/", + "^node_modules/", ] load-plugins = ["pylint_pydantic"] persistent = false @@ -230,3 +231,30 @@ ignore = [ [tool.ruff.lint.mccabe] max-complexity = 40 + +[tool.pyright] +pythonVersion = "3.12" +typeCheckingMode = "strict" +exclude = [ + "**/node_modules", + "**/__pycache__", + "**/.*", + "build/", +] +reportArgumentType = false +reportAttributeAccessIssue = false +reportMatchNotExhaustive = false +reportMissingTypeStubs = false +reportPrivateUsage = false +reportTypedDictNotRequiredAccess = false +reportUnknownArgumentType = false +reportUnknownLambdaType = false +reportUnknownMemberType = false +reportUnknownVariableType = false +reportUnnecessaryComparison = false + +# Additional flags that are not included in strict mode +deprecateTypingAliases = true +reportImplicitOverride = true +reportImportCycles = false +reportPropertyTypeMismatch = true