Skip to content

Commit

Permalink
Sync with template
Browse files Browse the repository at this point in the history
  • Loading branch information
blakeNaccarato committed Jul 9, 2024
1 parent ea1da5f commit 09c2cbd
Show file tree
Hide file tree
Showing 15 changed files with 57 additions and 43 deletions.
2 changes: 1 addition & 1 deletion .copier-answers.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Changes here will be overwritten by Copier; NEVER EDIT MANUALLY
_commit: 2024.1.1-64-ge91f8ef
_commit: 2024.1.1-91-g2217ca3
_src_path: gh:blakeNaccarato/copier-python
actions_runner: ubuntu-22.04
active: true
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,9 @@ jobs:
with:
python-version: "${{ matrix.python }}"
- run: "scripts/Sync-Py.ps1"
- run: ". scripts/Initialize-Shell.ps1; pyright"
- uses: "jakebailey/pyright-action@3bdde3b31d26f0f1f5de051b1fbd7a536a9a4e7f" # v4.1.7
with:
pylance-version: "2024.6.1"
test:
needs: "sync"
strategy:
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/high.yml
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,9 @@ jobs:
with:
python-version: "${{ matrix.python }}"
- run: "scripts/Sync-Py.ps1"
- run: ". scripts/Initialize-Shell.ps1; pyright"
- uses: "jakebailey/pyright-action@3bdde3b31d26f0f1f5de051b1fbd7a536a9a4e7f" # v4.1.7
with:
pylance-version: "2024.6.1"
test:
needs: "sync"
strategy:
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ examples
# * -------------------------------------------------------------------------------- * #
# * Template gitignore

# local workspace extensions directory
.vscode/extensions
# uv binary
bin
# Locally-compiled dependencies
Expand Down
3 changes: 0 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
[submodule "template"]
path = submodules/template
url = https://github.com/blakeNaccarato/copier-python.git
[submodule "typings"]
path = submodules/typings
url = https://github.com/blakeNaccarato/pylance-stubs-unofficial.git
[submodule "boilercore"]
path = submodules/boilercore
url = https://github.com/softboiler/boilercore.git
10 changes: 9 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ ci:
- "fawltydeps-docs"
- "fawltydeps-scripts"
- "fawltydeps-tests"
- "pyright"
- "pytest-fast-only"
- "synchronize-params"
autoupdate_schedule: "quarterly"
Expand Down Expand Up @@ -66,12 +67,19 @@ repos:
files: "^tests/.*$"
entry: |
pwsh -Command ". scripts/Initialize-Shell.ps1; fawltydeps --config-file tests/pyproject.toml"
- id: "pyright"
name: "pyright"
pass_filenames: false
language: "system"
entry: |
pwsh -Command ". scripts/Initialize-Shell.ps1; pyright"
types_or: ["python", "pyi"]
- id: "pytest-fast-only"
name: "pytest-fast-only"
pass_filenames: false
language: "system"
entry: |
pwsh -Command ". scripts/Initialize-Shell.ps1; pytest -m 'not slow' --suppress-no-test-exit-code"
pwsh -Command ". scripts/Initialize-Shell.ps1; pytest -m 'not slow'"
files: |
(?x)^(
.*/pyproject\.toml
Expand Down
6 changes: 0 additions & 6 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"recommendations": [
"aaron-bond.better-comments",
"bierner.markdown-preview-github-styles",
"charliermarsh.ruff",
"davidanson.vscode-markdownlint",
"donjayamanne.githistory",
"eamodio.gitlens",
Expand All @@ -13,17 +12,12 @@
"github.vscode-github-actions",
"github.vscode-pull-request-github",
"ms-azuretools.vscode-docker",
"ms-python.debugpy",
"ms-python.python",
"ms-python.vscode-pylance",
"ms-toolsai.jupyter",
"ms-vscode.powershell",
"ms-vscode-remote.remote-containers",
"njpwerner.autodocstring",
"njpwerner.autodocstring",
"redhat.vscode-yaml",
"rodolphebarbanneau.python-docstring-highlighter",
"rodolphebarbanneau.python-docstring-highlighter",
"ryanluker.vscode-coverage-gutters",
"sourcery.sourcery",
"stkb.rewrap",
Expand Down
14 changes: 0 additions & 14 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -149,13 +149,6 @@
"icon": { "id": "file-symlink-directory" },
"problemMatcher": []
},
{
"label": "setup: Finish initializing machine (cross-platform)",
"type": "shell",
"command": "scripts/Initialize-Machine.ps1",
"icon": { "id": "file-symlink-directory" },
"problemMatcher": []
},

// * -------------------------------------------------------------------------- * //
// * OTHER TASKS * //
Expand Down Expand Up @@ -188,13 +181,6 @@
"icon": { "id": "versions" },
"problemMatcher": []
},
{
"label": "task: Run pytest with coverage",
"type": "shell",
"command": ". scripts/Initialize-Shell.ps1; pytest --cov --cov-config pyproject.toml --cov-report xml",
"icon": { "id": "check" },
"problemMatcher": []
},
{
"label": "task: Run ruff",
"type": "shell",
Expand Down
12 changes: 7 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@ email = "[email protected]"
[tool.coverage.run]
branch = true
source = ["boilerdaq", "boilerdaq_docs", "boilerdaq_tests", "boilerdaq_tools"]
[tool.coverage.report]
ignore_errors = true

[tool.fawltydeps]
deps = ["pyproject.toml"]
code = ["src"]
Expand All @@ -59,12 +58,17 @@ ignore_unused = ["libusb", "pyusb", "pyvisa-py", "pyvisa-sim", "zeroconf"]
boilercore = ["boilercore"]

[tool.pytest.ini_options]
# ! https://github.com/pytest-dev/pytest-cov/issues/479#issuecomment-1247444988
addopts = '''
--strict-config
--strict-markers
--color yes
--suppress-no-test-exit-code
--color=yes
-p no:legacypaths
-r a
--cov
--cov-config=pyproject.toml
--cov-report=xml
'''
cache_dir = ".cache/.pytest_cache"
markers = "slow"
Expand Down Expand Up @@ -104,12 +108,10 @@ exclude = [
"**/AppData",
"bin",
"submodules/template",
"submodules/typings",
"submodules/**/docs",
"submodules/**/scripts",
"submodules/**/tests",
]
stubPath = "submodules/typings"
typeCheckingMode = "strict"
# Default "true" in strict
analyzeUnannotatedFunctions = true
Expand Down
14 changes: 7 additions & 7 deletions scripts/Initialize-Machine.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,21 @@ Finish machine initialization (cross-platform).#>
. scripts/Initialize-Shell.ps1

# Set Git username if missing
try { $name = git config --global 'user.name' }
try { $name = git config 'user.name' }
catch [System.Management.Automation.NativeCommandExitException] { $name = '' }
if (!$name) {
git config --global 'user.name' "$((Get-Content '.copier-answers.yml' |
Select-String -Pattern '^project_owner_github_username:\s(.+)$').Matches.Groups[1].value)"
# Have Git auto set up local branches to track remote branches if not yet configured
try { $name = git config --global 'push.autoSetupRemote' }
catch [System.Management.Automation.NativeCommandExitException] { $name = '' }
if (!$name) { git config --global 'push.autoSetupRemote' 'true' }
try { $auto = git config 'push.autoSetupRemote' }
catch [System.Management.Automation.NativeCommandExitException] { $auto = '' }
if (!$auto) { git config --global 'push.autoSetupRemote' 'true' }
}

# Set Git email if missing
try { $name = git config --global 'user.email' }
catch [System.Management.Automation.NativeCommandExitException] { $name = '' }
if (!$name) {
try { $email = git config 'user.email' }
catch [System.Management.Automation.NativeCommandExitException] { $email = '' }
if (!$email) {
git config --global 'user.email' "$((Get-Content '.copier-answers.yml' |
Select-String -Pattern '^project_email:\s(.+)$').Matches.Groups[1].value)"
}
Expand Down
1 change: 0 additions & 1 deletion scripts/Initialize-Repo.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ catch [System.Management.Automation.NativeCommandExitException] { $fresh = $true
git add .
git commit --no-verify -m 'Prepare template using blakeNaccarato/copier-python'
git submodule add --force --name template 'https://github.com/blakeNaccarato/copier-python.git' submodules/template
git submodule add --force --name typings 'https://github.com/blakeNaccarato/pylance-stubs-unofficial.git' submodules/typings
git add .
git commit --no-verify -m 'Add template and type stub submodules'
scripts/Sync-Py.ps1
Expand Down
3 changes: 2 additions & 1 deletion scripts/Initialize-Shell.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,15 @@ if ($IsWindows) {
}

# ? Environment variables
$Env:PIP_DISABLE_PIP_VERSION_CHECK = 1
$Env:PYRIGHT_PYTHON_PYLANCE_VERSION = '2024.6.1'
$Env:PYDEVD_DISABLE_FILE_VALIDATION = 1
$Env:PYTHONIOENCODING = 'utf-8:strict'
$Env:PYTHONUTF8 = 1
$Env:PYTHONWARNDEFAULTENCODING = 1
# Ignore warnings until explicitly re-enabled in tests
$Env:PYTHONWARNINGS = 'ignore'

# ? Environment setup
function Set-Env {
<#.SYNOPSIS
Load `.env`, activate a virtual environment found here or in parent directories.#>
Expand Down
20 changes: 20 additions & 0 deletions scripts/Sync-Py.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,26 @@ elseif ($Devcontainer) { $msg = 'devcontainer' }
elseif ($Release) { $msg = 'release' }
"Will run $msg steps" | Write-Progress -Info

if (!$CI -and
(Get-Command -Name 'code' -ErrorAction 'Ignore') -and
!(code --list-extensions | Select-String -Pattern 'charliermarsh.ruff', 'ms-python.vscode-pylance')
) {
'INSTALLING LOCAL VSCODE WORKSPACE EXTENSIONS' | Write-Progress
if (Get-Command -Name 'code' -ErrorAction 'Ignore') { $py = 'py' }
$Install = @(
'--extensions-dir=.vscode/extensions',
'[email protected]',
'[email protected]'
)
code @Install
# Remove local Pylance bundled stubs
Get-ChildItem -Path '.vscode/extensions' -Filter 'ms-python.vscode-pylance-*' |
ForEach-Object {
Get-ChildItem -Path "$($_.FullName)/dist/bundled" -Filter '*stubs'
} |
Remove-Item -Recurse
'INSTALLED LOCAL VSCODE WORKSPACE EXTENSIONS' | Write-Progress -Done
}
'FINDING UV' | Write-Progress
$uvVersionRe = Get-Content 'requirements/uv.txt' | Select-String -Pattern '^uv==(.+)$'
$uvVersion = $uvVersionRe.Matches.Groups[1].value
Expand Down
4 changes: 3 additions & 1 deletion scripts/boilerdaq_tools/sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,12 +253,14 @@ def get_subs() -> dict[str, Dep]:
op=" @ ", rev=f"git+{subs[path]}@{revs[path]}"
)
for path in subs
if path not in {"submodules/template", "submodules/typings"}
if path != "submodules/template"
}


def get_submodule_info(kind: SubmoduleInfoKind) -> list[str]:
"""Get submodule info."""
if not Path(".gitmodules").exists():
return []
return [
item.split()[1].removesuffix(".git")
for item in run(
Expand Down
1 change: 0 additions & 1 deletion submodules/typings
Submodule typings deleted from 37d486

0 comments on commit 09c2cbd

Please sign in to comment.