In the middle of the desert you can say anything you want
github/git-sizer: Compute various size metrics for a Git repository, flagging those that might cause problems (linked by Repository limitations and recommendations)
TL;DR too many files? too large one? too many tags? Find out!
yay took forever to compress pycharm. Like, 5-10 mins at least.
TODO documentation, but if you don’t care about package size but care about speed, this will speed up everything considerably:
PKGEXT='.pkg.tar' yay -S pycharm-professional
So Slicer seems to use both and I need to as well, so I’ll have to learn that sooner or later.
open-source, cross-platform library that provides developers with an extensive suite of software tools for image analysis (About | ITK)
there’s a python package docu:
In pycharm, updated black to use these args:
--preview --enable-unstable-feature string_processing $FilePath$
The (future of the) Black code style - Black 24.8.0 documentation has both the preview style and the unstable features one can enable (by passing the flag multilple times).
string_processing breaks long strings into multiple shorter ones, one on each line.
Useful:
mypy cares about packages, especially __init__.py files — the uppermost dir with such a file will be the root package. See Mapping files to modules - Running mypy and managing imports - mypy 1.12.0+dev.ecfab6a02415c46eda5717ec6ee9bfac8115c1e9.dirty documentation
This is needed to do per-package configs
[mypy-mycode.package.etc]
disable_error_code = attr-defined, union-attr
tuple[Path, ...] means tuple containing any number of Path objectsProblem: the pycharm extension I have crashes in the last version. :(
Main and best: python - How to run Pylint with PyCharm - Stack Overflow
My changes:
--msg-template="{abspath}:{line:5d},{column:2d}: {C}/{msg} ({symbol})" --output-format=colorized "$FilePath$"
", otherwise it failed for me, and {C} — for the message class see man page (or below) for list of format string options.$FILE_PATH$:\s*$LINE$\,\s*$COLUMN$I had two options as separate tools:
$FileParentDir$ at the end.--recursive=y — fails on no __init__.py otherwiseWorked neatly with a .pylintrc file in repo root with e.g.
[tool.pylint.main]
[tool.pylint.basic]
# "too-few-public-methods", disable
min-public-methods=0
function-naming-style="camelCase"
argument-naming-style="camelCase"
method-naming-style="camelCase"
variable-naming-style="camelCase"
attr-naming-style="camelCase"
[tool.pylint."messages control"]
disable = [
"fixme", # TODOs
"import-error", # runner has them in its environment
"import-outside-toplevel", # explicit requirement of XXX to import where used
"duplicate-code" # entangling different extensions/modules is not the solution
]
Pylint format string options from man pylint:
path relative path to the file
abspath
absolute path to the file
line line number
column column number
end_line
line number of the end of the node
end_column
column number of the end of the node
module module name
obj object within the module (if any)
msg text of the message
msg_id the message code (eg. I0011)
symbol symbolic name of the message (eg. locally-disabled)
C one letter indication of the message category
category
fullname of the message category
For example, the former (pre 1.0) default format can be obtained with:
pylint --msg-template='{msg_id}:{line:3d},{column}: {obj}: {msg}'
If I have this post open, I’ll need this one anyway: Messages control - Pylint 4.0.0-dev0 documentation
Also here’s more randomness that I have nowhere else to put:
[tool.pylint.main]
load-plugins=pylint_pydantic
[tool.pylint.basic]
disable=logging-fstring-interpolation
uv run pylint --max-line-length=88 --fail-under=9 (find src -regextype egrep -regex '(.*.py)$') --output-format=colorized --msg=template="{path}:{line}:{category}: {msg_id}: {msg} ({symbol})"
Is ‘file’ a keyword in python? - Stack Overflow
TL;DR python3 doesn’t care about file, regardless of what syntax highlighters think about this.
TL;DR:
docstring-convention=google in flake8 config file, ignores there as well together with the rest.pydocstyle / python-flake8-docstrings is a thing. Forgot I had it installed and spent a lot of time trying to understand pycharm’s output
Usage — pydocstyle 0.0.0.dev0 documentation flake8-docstrings · PyPI
To ignore things, you don’t do:
[pydocstyle]
convention = google
ignore = D401
It’s either ignore or convention. Which quietly happened in the background, and I thought it doesn’t read my config file since D401 was still shown.
Correct would be this:
[pydocstyle]
convention = google
add-ignore = D401
EDIT GodDAMN it, pydocsyle parsing a config file doesn’t mean that flake8(-..docstring) will.
Reading the flake8 plugin docs, I should add THIS and to flake8 config file. Ignores also are set up there using the usual way.
docstring-convention=google
And the pydoctest config file search and add-ignore is irrelevant. God lost so much time to this
EDIT: this may be all wrong, in the debugger I can just edit the code and it gets automatically used by slicer — logical, since it’s just a CLI script.
It’s the .xml with the interface that’s problematic and it can’t be reloaded using the method below, or at least I couldn’t.
A scriptedcli module imported to Slicer doesn’t show for me the usual “reload” buttons as seen in scripted modules in dev. mode. To develop, I need my changes I need to reload it w/o restarting 3dslicer.
Based on this more complete example1 linked in the script repository2
>>> mpath = "/full/path/to/the/my_module.py"
>>> factoryManager = slicer.app.moduleManager().factoryManager()
>>> factoryManager.registerModule(qt.QFileInfo(mpath))
>>> factoryManager.loadModules(["my_module"])
True
BONUS:
import pydevd_pycharm
pydevd_pycharm.settrace('localhost', port=5678, stdoutToServer=True, stderrToServer=True)