modernize repo tooling: ruff, pre-commit, CI, ty (astral type checker), uv#272
Open
vlordier wants to merge 3 commits intoeasyw:masterfrom
Open
modernize repo tooling: ruff, pre-commit, CI, ty (astral type checker), uv#272vlordier wants to merge 3 commits intoeasyw:masterfrom
vlordier wants to merge 3 commits intoeasyw:masterfrom
Conversation
There was a problem hiding this comment.
Pull request overview
Modernizes the repository’s Python/tooling workflow around the Astral ecosystem (ruff/uv/ty), adding pre-commit and GitHub Actions CI, and applies broad automated formatting/cleanup across the codebase to align with the new tooling.
Changes:
- Added
pyproject.tomlconfiguration for ruff (lint/format), uv, and ty. - Added pre-commit hooks, CI workflow, dependabot updates, and editor settings for consistent automation.
- Applied repo-wide Python formatting/cleanup and adjusted various scripts/modules accordingly.
Reviewed changes
Copilot reviewed 34 out of 39 changed files in this pull request and generated 12 comments.
Show a summary per file
| File | Description |
|---|---|
pyproject.toml |
Adds ruff/uv/ty configuration and excludes selected paths from lint/type analysis. |
.pre-commit-config.yaml |
Adds ruff + standard pre-commit hooks. |
.github/workflows/ci.yml |
Adds CI jobs for ruff lint/format, pre-commit, and ty. |
.github/dependabot.yml |
Enables weekly Dependabot updates for actions and pip. |
.editorconfig |
Standardizes editor defaults (indent, LF, UTF-8, trimming, etc.). |
.gitattributes |
Enforces LF normalization and sets diff/binary attributes for common file types. |
.gitignore |
Adds ignores for Python/tooling/editor caches. |
utf8test.py |
Refactors string/encoding helpers and applies formatting (but introduces unreachable/py2-era remnants). |
test-mb.py |
Formatting and minor import cleanup in test UI script. |
step_amend.py |
Formatting and minor refactor of gzip/step transparency rewrite helper. |
selection2edges.py |
Formatting and import cleanup; minor refactor of view-direction logic and placement operations. |
makefacedxf.py |
Formatting + import cleanup; refactors DXF import paths and related logic. |
ksu_locator.py |
Formatting and import cleanup. |
hlp.py |
Formatting and import cleanup. |
fcad_parser/test.py |
Formatting and modernization (but keeps an argparse filename indexing bug). |
fcad_parser/sexp_parser/test.py |
Formatting and modernization (but keeps an argparse filename indexing bug). |
fcad_parser/kicad_pcb.py |
Docstring normalization and formatting; minor tuple/list refactors. |
explode.py |
Formatting and light refactors; introduces a dead/no-op expression in geometry placement helper. |
expTree.py |
Formatting and minor boolean simplification. |
dxf_parser/_dxfReader.py |
Large formatting pass and py3 simplification (but now misses an import needed at runtime). |
dxf_parser/_dxfColorMap.py |
Pure formatting of color map literal. |
constrainator.py |
Formatting and refactors for readability (loops/conditions); keeps legacy branches. |
commits_num.py |
Formatting and modernization; refactors request URL building (but introduces requests scoping bug). |
_DXF_Import.py |
Formatting/import cleanup; DXF import wrapper adjustments (but introduces missing translate dependency). |
ZipStepImport.py |
Formatting/import cleanup; zip import wrapper adjustments (but introduces missing translate dependency). |
TranslateUtils.py |
Formatting; changes translation fallback behavior (but removes a required fallback). |
SaveSettings.py |
Formatting and reload helper simplification. |
InitGui.py |
Large formatting/refactor pass across workbench initialization and UI setup. |
Init.py |
Formatting (but removes import FreeCAD causing import-time failure). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| decodedName = name.decode("latin1") | ||
| except UnicodeDecodeError: | ||
| FreeCAD.Console.PrintError(translate("Zip import","Error: Couldn't determine character encoding")) | ||
| FreeCAD.Console.PrintError(translate("Zip import", "Error: Couldn't determine character encoding")) |
Comment on lines
+259
to
263
| f = Part.makeFace(w, "Part::FaceMakerBullseye") | ||
| except Part.OCCError: # Exception: # | ||
| # FreeCAD.Console.PrintError('Error in source %s (%s)' % (faceobj.Name,faceobj.Label)+"\n") | ||
| FreeCAD.Console.PrintError('Error in source %s (%s)' % (f.Name,f.Label)+"\n") | ||
| FreeCAD.Console.PrintError("Error in source %s (%s)" % (f.Name, f.Label) + "\n") | ||
|
|
Comment on lines
+18
to
+21
| FreeCAD.addImportType("Kicad pcb board File Type (*.kicad_pcb)", "kicadStepUptools") | ||
| FreeCAD.addImportType("Kicad pcb mod File Type (*.kicad_mod)", "kicadStepUptools") | ||
|
|
||
| FreeCAD.addImportType("zip of STEP/FCStd File Type (*.zip)","ZipStepImport") | ||
| FreeCAD.addImportType("zip of STEP/FCStd File Type (*.zip)", "ZipStepImport") |
| decodedName = name.decode("latin1") | ||
| except UnicodeDecodeError: | ||
| FreeCAD.Console.PrintError(translate("Zip import","Error: Couldn't determine character encoding")) | ||
| FreeCAD.Console.PrintError(translate("Zip import", "Error: Couldn't determine character encoding")) |
Comment on lines
52
to
+57
| def latestCommitInfo(u, r): | ||
| """ Get info about the latest commit of a GitHub repo """ | ||
| response = requests.get('https://api.github.com/repos/{}/{}/commits?per_page=1'.format(u, r)) | ||
| commit = response.json()[0]; commit['number'] = re.search(r'\d+$', response.links['last']['url']).group() | ||
| return commit | ||
| """Get info about the latest commit of a GitHub repo""" | ||
| response = requests.get(f"https://api.github.com/repos/{u}/{r}/commits?per_page=1") | ||
| commit = response.json()[0] | ||
| commit["number"] = re.search(r"\d+$", response.links["last"]["url"]).group() | ||
| return commit |
Author
|
@copilot apply changes based on the comments in this thread |
25d2082 to
370ae98
Compare
Author
|
@copilot apply changes based on the comments in this thread |
…, editorconfig - pyproject.toml: ruff lint + format (py311, 120 cols, 20 rule sets), ty type checker, uv config - .pre-commit-config.yaml: ruff lint/fix + ruff-format + ty + standard hooks - .github/workflows/ci.yml: 3 jobs (ruff lint+format, pre-commit, ty) - .github/dependabot.yml: weekly updates for actions and pip - .editorconfig: 4-space indent, LF, UTF-8 - .gitattributes: LF normalization, binary file markers - .gitignore: ruff_cache, __pycache__, uv, editor temp files - .git-blame-ignore-revs: record formatting commit for git blame skip
Apply ruff format (4-space indent, double quotes, 120 cols) and ruff check --fix + --unsafe-fixes across all 23 first-party .py files. Includes: import sorting, f-strings, trailing whitespace, useless semicolons, comprehension simplifications (C416/C419), needless-bool (SIM103), isinstance merges (SIM101), manual-list-copy (PERF402), trailing commas (COM812), and more. Third-party submodules (fcad_parser/, dxf_parser/) excluded.
…, etc.) Manual fixes across 19 files: - SIM103: inline boolean returns (kicadStepUpCMD, kicadStepUptools) - SIM115: with statements for file handles (exchangePositions, fps, kicadStepUptools, kicad_parser) - SIM113: enumerate() replaces manual counters (kicadStepUptools, tracks) - PERF402: .extend() replaces manual list copy loops (constrainator, kicadStepUpCMD, kicadStepUptools, kicad_parser) - UP031: printf-style to f-strings (kicadStepUptools) - RUF003: unicode chars in comments (kicadStepUptools, tracks) - YTT201: sys.version_info == 3 -> >= 3 (kicadStepUptools, kicad_parser) - TRY: logger.exception redundant exception arg (kicad_parser) - Copilot review fixes: import FreeCAD (Init.py), translate fallback (TranslateUtils.py), import scope (commits_num.py, ZipStepImport.py, _DXF_Import.py), dead expression (explode.py), dead Py2 code (utf8test.py), except block (makefacedxf.py)
fa87e85 to
c5307c6
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Modernise the repository toolchain with the astral-sh ecosystem (ruff, uv, ty), pre-commit hooks, and GitHub Actions CI.
How to review this PR
c5307c67cb876097650ddNew files
pyproject.toml.pre-commit-config.yaml.github/workflows/ci.yml.github/dependabot.yml.editorconfig.git-blame-ignore-revsgit blame --ignore-revs-fileChanges applied
Auto-fixes (commit 2 — formatting only)
ruff format + ruff check --fix: import sorting, f-strings, unicode prefix removal, trailing whitespace, useless semicolons, comprehension simplifications, trailing commas, collapsible else-if.
Semantic fixes (commit 3 — manual)
if cond: return True/False→return condisinstance(x, A) or isinstance(x, B)→isinstance(x, (A, B))for x in y: list.append(x)→list.extend(y)/list()open()/close()→with open()context managerenumerate()%sprintf-style → f-strings== 3→>= 3for Python 4 compatlogger.exception(f"...{ex}")→logger.exception("...")makefacedxf.py: re-encoded ISO-8859 → UTF-8Copilot review fixes
TranslateUtils.py: definetranslate()fallback when FreeCAD has noQtInit.py: restoreimport FreeCAD(removed by ruff F401 pass)commits_num.py: addimport requestsinsidelatestCommitInfo()ZipStepImport.py/_DXF_Import.py: addfrom TranslateUtils import translatemakefacedxf.py: fix undefinedf.Nameinexcept Part.OCCErrorexplode.py: comment out dead/disconnected expressionutf8test.py: remove unreachable Python 2 dead codeThird-party submodules excluded
fcad_parser/anddxf_parser/(git submodules) are excluded from all tooling. The only change is a 2-line flake8 comment removal fromdxf_parser/_importDXF.py.Ruff rules still silenced (future cleanup)
Complexity (PLR09xx), magic numbers (PLR2004), globals (PLW06xx), line length (E501), bare except (E722), lazy imports (E402), star imports (F403/405), undefined names (F821), ambiguous var names (E741), private access (SLF001), print (T201).
Local dev workflow