Skip to content


ardupilot  None  ros2  dds  micro ros  xrce  lua  sitl  scripts  plugin  gazebo  garden  SITL  debug  mavlink  gimbal  rangefinder  pymavlink  mavros  distance sensor  system_time  timesync  ardurover  script  cheat sheet  wireshark  mavproxy  mission planner  pixhawk  cpp  index  cmake  gtest  ctest  demo  101  variables  cpack  deb  package  dpkg  eigen  linear algebra  c++  format  fmt  smart pointers  data structure  map  container  multithreading  spdlog  cyclonedds  eprosima  fastdds  aptly  apt  repository  repo  local  mirror  encryption  pgp  docker  arm  qemu  state  networking  network  template  python  app  devcontainer  gui  tutorial  tips  volume  mount  compose  multi-stage  stage  docker compose  microsoft  dotnet  .net  c#  vscode  git  branch  tag  bundle  backup  hooks  pre-commit  submodules  marpit  presentation  marp  markdown  mermaid  mkdocs  video  ffmpeg  gstreamer  cheat-sheet  sdp  nvidia  opencv  appsrc  appsink  acceleration  va-api  intel  v4l2loopback  pipe  compositor  alpha  shmsink  shmsrc  intersink  intersrc  tee  queue  udp  stream  klv  misb  mpeg-ts  gst  mpeg  metadata  binding  gi  kml  geo  gis  spatial  gdal  ogr  raster  vector  qgc  qgroundcontrol  snippets  cheat Sheet  asyncio  event  future  thread  task  can  canbus  click  cli  cupy  numpy  gpu  dataclass  slots  dev container  fastapi  rest  uvicorn  debian  setup  stdeb  project  jupyter  widgets  interactive  plot  matplotlib  ipywidgets  3d  subplot  open3d  point cloud  packaging  pyproject  pipx  package manager  black  isort  templates  cookiecutter  docs  project document  docstrings  flake8  linter  git-hook  mypy  unittest  pytest  pylint  from a-z  fixture  scope  logging  pytest.ini  mock  parameterize  enum  flag  iterator  generator  yaml  yml  logging config  tuple  namedtuple  typing  annotation  generic  literal  protocol  self  typed dict  typevar  pyzmq  zmq  msgpack  slam  cartographer  slam_toolbox  build system  colcon  action  namespace  remap  control2  diff-drive  ignition  ros2_control  effort  velocity  gdb  mix  multi language  qos  plugins  ros  pub  sub  msg  node  time  rclcpp  parameters  zero-copy  shm  loan message  rmw  image  large message  discovery  zenoh  bridge  zenoh-plugin-ros2dds  pico  algorithm  calibration  diff  pid  dev  colcon_cd  clean  custom  bloom  rpi  core  settings  behavior  py_trees  bt  behavior_trees  blackboard  visualization  debugging  diagnostic  DiagnosticTask  rclpy  tutorials  diagnostics  math  ned  enu  coordinate  apm  rat_runtime_monitor  bag  rosbag  rosbags  tools  smach  state machine  yasmin  web  rosbridge  vue  profile  gazebo-classic  launch  spawn  model  cook  camera  sensors  gps  imu  ray  gazebo_ros_ray_sensor  lidar  ultrsonic  range  ultrasonic  gazebo classic  wrench  gazebo_ros_state  gz  sdf  world  vscode tips  gazebogz-sim-joint-position-controller-system  simulation  ros_gz_bridge  ign  xacro  diff_drive  odom  odometry  joint_state  argument  OpaqueFunction  DeclareLaunchArgument  LaunchConfiguration  tmux  tmuxp  nav  nav2  turtlebot  perception  tf  vision  cv_bridge  setup.py  name  test  goal abort  cancel goal  action client  action server  custom messages  executor  MultiThreadedExecutor  SingleThreadedExecutor  lifecycle  parameter  param  dynamic-reconfigure  get  global server  persist_parameter  service  client  package.xml  msgs  executers  rep  rqt  humble  rviz  rviz2  pose  marker  tf2  static  graphro  local_setup  rosdep  project settings  vcstool  urdf  robot_state_publisher  urdf_to_graphiz  joint  link  robotics  path planning  trajectory  speed  filters  control  kalman_filter  kalman  filter  pcl  fusing  foc  bldc  arduino  drv8313  simple foc  quaternions  euler  rotation  code  extensions  remote  cache  offline  ssh  tasks  json  schema  server  deep learning  ai  beginner  regression  reinforcement learning  q learning  gym  gymnasium  deepsort  onnx  inference  build  source  wheel  cuda  siam-mask  tracking  segmentation  yolo  ultralytics  yolov8  jetson  tensorrt  rest api  js  javascript  async  alpine.js  mqtt  nano  terabee  i2c  l6234  blink  platformio  lw20  benewake  TF03  serial  tf_mini  libs  cross-compiler  esp32  idf  esp-idf  rtos  hello world  mp6050  mpu9250  mpu6050  embedded  kconfig  semaphore  mutex  timer  adafruit  sensor  mb1202  uart  tfmini  gpio  raspberry pi  arducam  lidat  ubuntu  stm32  nucleo  mbed  blue pill  swd  library  teensy  microros  udev  rule  usb  micro python  pymakr  config  material  workshope  classic  texture  topic  gzstring  position  force  joints  loop device  rootfs  linux  rm  sudo  sudoers  nopasswd  visudo  shell  key  gpg  sign  commands  update-alternative  debconf  dpkg-show  dpkg-reconfigure  debconf-communicate  ip  ss  netstat  systemd  socat  tc  mtu  select  projects  courses to follow  matrix  graphics  2d  course  storm32  deploy  drone  quad  uav  geometric control  se3  so3  joint_states  JointState  Header  rrbot  JointTrajectory  gazebo_ros_joint_pose_trajectory  vrx  buoyancy 

pylint#

Linting is the automated source code checking for programmatic and stylistic errors.
A lint tool is a basic static code analyzer

pylint is default VSCode linter and it enable by default

install#

install
pip install pylint

VSCode#

Settings#

vscode settings
"python.linting.pylintEnabled": true

Extensions#

pylint extension for Visual Studio Code

  • Execute pylint automatically on python file
  • bundle with pylint can changed by settings pylint.path

Control#

control pylint with rules file .pylintrc

pylintrc file location

  • /etc/pylintrc
  • ~/pylintrc
  • <project_path>/pylintrc
create pylintrc
pylint --generate-rcfile > pylintrc

VSCode

VSCode look automaticly for pylintrc at the project root

pylintrc

pre-commit git hook not found the pylintrc file if we prefix it with dot (.pylintrc)

VSCode file mapping

map pylintrc file to ini type

"files.associations": {
    "pylintrc": "ini"
},

Demo#

minimal pylintrc file to disabled checker message

[MASTER]
disable=
    C0114, # (missing-module-docstring)
    C0115,  # (missing-class-docstring)

Demo II#

Add rules inline

  • Add comment to end of line
# pylint: disable=[problem-code]

# pylint: disable=unused-private-member


Run manual#

~/.local/bin/pylint <file full path>
~/.local/bin/pylint --rcfile=<config_file> <file full path>
demo
~/.local/bin/pylint --rcfile pylintrc  pylint_demo.py
************* Module pylint_demo
pylint_demo.py:2:4: R0201: Method could be a function (no-self-use)
pylint_demo.py:1:0: R0903: Too few public methods (1/2) (too-few-public-methods)

git hook#

  • Install pre-commit python util
  • Add .pre-commit-config.yaml
  • Run pre-commit install
  • Add files to stage
  • Run pre-commit run or try commit stage files
install
pip install pre-commit
.pre-commit-config.yaml
repos:
  - repo: local
    hooks:
      - id: pylint
        name: pylint
        entry: pylint
        language: system
        types: [python]
        args: 
            [
            "--rcfile=pylintrc"
            ]

Demo#

 ~/.local/bin/pre-commit run
[WARNING] Unstaged files detected.
[INFO] Stashing unstaged files to /home/user/.cache/pre-commit/patch1681097484-36170.
pylint...................................................................Failed
- hook id: pylint
- exit code: 8

************* Module pylint_demo
linters/pylint_demo.py:1:0: R0903: Too few public methods (1/2) (too-few-public-methods)

-------------------------------------------------------------------
Your code has been rated at 6.67/10 (previous run: 10.00/10, -3.33)



[INFO] Restored changes from /home/user/.cache/pre-commit/patch1681097484-36170.

pylintrc template#

[MASTER]
disable=
    C0114, # (missing-module-docstring)
    C0115, # (missing-class-docstring)
    C0116, # (missing-function-docstring)

[FORMAT]
# Maximum number of characters on a single line.
max-line-length=120

[BASIC]
# Good variable names which should always be accepted, separated by a comma
good-names=x,y

Tips#

line disable#

import config.logging_settings # pylint: disable=unused-import

function scope disable#

def test():
    # Disable all the no-member violations in this function
    # pylint: disable=no-member
    ...
    # pylint: enable=no-member

Tips#

E1101:Module 'pygame' has no 'init' member
"python.linting.pylintArgs": [
    "--extension-pkg-whitelist=extensionname" // comma separated
]

// or

"python.linting.pylintArgs": [
    "--unsafe-load-any-extension=y"
]

Reference#