Skip to content
Snippets Groups Projects
Commit d81b89a0 authored by Xuefeng Ding's avatar Xuefeng Ding
Browse files

update astroid

parent f66e820b
No related branches found
No related tags found
No related merge requests found
ci:
autoupdate_commit_msg: "chore: update pre-commit hooks"
autofix_commit_msg: "style: pre-commit fixes"
autoupdate_schedule: monthly
repos:
- repo: https://gitlab.cern.ch/pre-commit-hook-mirrors/pre-commit/pre-commit-hooks
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
- id: check-added-large-files
......@@ -17,25 +18,36 @@ repos:
- id: requirements-txt-fixer
- id: trailing-whitespace
- repo: https://gitlab.cern.ch/pre-commit-hook-mirrors/kynan/nbstripout
- repo: https://github.com/kynan/nbstripout
rev: 0.8.0
hooks:
- id: nbstripout
types_or: [jupyter]
- repo: https://gitlab.cern.ch/pre-commit-hook-mirrors/pre-commit/mirrors-clang-format
- repo: https://github.com/pre-commit/mirrors-clang-format
rev: v19.1.3
hooks:
- id: clang-format
types_or: [c++, c, cuda]
- repo: https://gitlab.cern.ch/pre-commit-hook-mirrors/psf/black-pre-commit-mirror
- repo: https://github.com/psf/black-pre-commit-mirror
rev: 24.10.0 # Use the latest stable version
hooks:
- id: black-jupyter
- repo: https://github.com/pycqa/isort
rev: 5.13.2
hooks:
- id: isort
name: isort (python)
- repo: https://github.com/Lucas-C/pre-commit-hooks
rev: "v1.5.5"
hooks:
- id: remove-tabs
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.7.3 # Use the latest version
rev: v0.7.4 # Use the latest version
hooks:
- id: ruff
args: ["--fix", "--show-fixes"]
......@@ -47,20 +59,20 @@ repos:
types: [file]
files: (\.cmake|CMakeLists.txt)(.in)?$
# - repo: https://gitlab.cern.ch/pre-commit-hook-mirrors/codespell-project/codespell
# - repo: https://github.com/codespell-project/codespell
# rev: v
# hooks:
# - id: codespell
# args: ["-L", "sur,falsy,gaus,hist,lsit,nd,parms,retur,ue,ba,claus,fo"]
# - repo: https://gitlab.cern.ch/pre-commit-hook-mirrors/pre-commit/pygrep-hooks
# - repo: https://github.com/pre-commit/pygrep-hooks
# rev: v
# hooks:
# - id: rst-backticks
# - id: rst-directive-colons
# - id: rst-inline-touching-normal
# - repo: https://gitlab.cern.ch/pre-commit-hook-mirrors/shellcheck-py/shellcheck-py
# - repo: https://github.com/shellcheck-py/shellcheck-py
# rev: v0.9.0.5
# hooks:
# - id: shellcheck
......
......@@ -29,5 +29,7 @@
"--function-arg-placeholders=false",
"--compile-commands-dir=build"
],
"clangd.path": "clangd-17"
"clangd.path": "clangd-17",
"jupyter.debugJustMyCode": false,
"debugpy.debugJustMyCode": false
}
......@@ -109,7 +109,6 @@ VS Marketplace Link: https://marketplace.visualstudio.com/items?itemName=ms-pyth
### python formatting
- pre-commit + vscode extensions
- install vscode extensions
- install extensions
```
Name: Black Formatter
......@@ -131,12 +130,22 @@ and update `settings.json`
```
- install pre-commit hooks
```
repos:
- repo: https://gitlab.cern.ch/pre-commit-hook-mirrors/psf/black
- repo: https://github.com/psf/black-pre-commit-mirror
rev: 24.10.0 # Use the latest stable version
hooks:
- id: black-jupyter
- repo: https://github.com/pycqa/isort
rev: 5.13.2
hooks:
- id: isort
name: isort (python)repos:
- repo: https://gitlab.cern.ch/pre-commit-hook-mirrors/psf/black-pre-commit-mirror
rev: 24.10.0 # Use the latest stable version
hooks:
- id: black
```
### c++ lint
- nox + vscode extensions
- setup nox
......@@ -204,8 +213,22 @@ and set
### python lint
#### ruff: pre-commit + vscode extensions
- install pre-commit
```yaml
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.7.3 # Use the latest version
hooks:
- id: ruff
args: ["--fix", "--show-fixes"]
```
- install extensions
```
Name: Ruff
Id: charliermarsh.ruff
Description: A Visual Studio Code extension with support for the Ruff linter.
Version: 2024.54.0
Publisher: Astral Software
VS Marketplace Link: https://marketplace.visualstudio.com/items?itemName=charliermarsh.ruff
```
#### pylint: nox + vscode extensions
......
......@@ -2,14 +2,14 @@ add_library(hello SHARED src/hello.cc)
target_include_directories(
hello PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
install(TARGETS hello LIBRARY DESTINATION .)
install(TARGETS hello LIBRARY DESTINATION _csrc)
add_library(complexf SHARED src/complexf.cc)
target_include_directories(
complexf PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
target_link_libraries(complexf PRIVATE hello)
install(TARGETS complexf LIBRARY DESTINATION .)
install(TARGETS complexf LIBRARY DESTINATION _csrc)
set_target_properties(complexf PROPERTIES INSTALL_RPATH "$ORIGIN")
# install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/include/" DESTINATION
......
%% Cell type:code id: tags:
``` python
import myproj.simulation as ms
import numpy as np
print(ms.add(1, 2))
print(ms.complex(1, 2))
print(np.array([1, 2, 3]))
```
%% Cell type:code id: tags:
``` python
import pylint
pylint.run_pylint(["myproj/simulation"])
```
%% Cell type:code id: tags:
``` python
from astroid.interpreter._import import util
print(util.is_namespace("myproj"))
```
......
......@@ -62,5 +62,8 @@ profile = "black"
disable = [
"C0114", # Missing module docstring
"C0115", # Missing class docstring
"C0116" # Missing function or method docstring
"C0116", # Missing function or method docstring
]
[tool.pylint.MASTER]
extension-pkg-allow-list = "myproj.simulation"
from ._csrc._hello import add, complex
from ._csrc._hello import add, complexf
from .core import div
__all__ = ["add", "complex", "div"]
__all__ = ["add", "complexf", "div"]
......@@ -7,4 +7,4 @@ find_package(pybind11 CONFIG REQUIRED)
pybind11_add_module(_hello MODULE _hello_python.cc)
target_link_libraries(_hello PRIVATE complexf)
install(TARGETS _hello DESTINATION _csrc)
set_target_properties(_hello PROPERTIES INSTALL_RPATH "$ORIGIN/..")
set_target_properties(_hello PROPERTIES INSTALL_RPATH "$ORIGIN")
"""
pybind11 example plugin
"""
from __future__ import annotations
__all__ = ["add", "complexf"]
def add(arg0: float, arg1: float) -> float:
"""
A function which adds two numbers
"""
def complexf(arg0: float, arg1: float) -> float:
"""
complex(a,b) = add(a,b) + 2
"""
......@@ -7,5 +7,5 @@ PYBIND11_MODULE(_hello, m) {
m.doc() = "pybind11 example plugin"; // optional module docstring
m.def("add", &add, "A function which adds two numbers");
m.def("complex", &complexf, "complex(a,b) = add(a,b) + 2");
m.def("complexf", &complexf, "complex(a,b) = add(a,b) + 2");
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment