{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "import myproj.simulation as ms\n",
    "import numpy as np\n",
    "\n",
    "print(ms.add(1, 2))\n",
    "print(ms.complex(1, 2))\n",
    "print(np.array([1, 2, 3]))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "import pylint\n",
    "\n",
    "pylint.run_pylint([\"myproj/simulation\"])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from astroid.interpreter._import import util\n",
    "\n",
    "print(util.is_namespace(\"myproj\"))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "import json\n",
    "from io import StringIO\n",
    "\n",
    "import pylint.lint\n",
    "from pylint.reporters import JSONReporter\n",
    "\n",
    "root = \"/datafs/users/dingxf/neutrino-physics-tutorial/scikit-build-cpp-python\"\n",
    "\n",
    "# Define the Pylint options\n",
    "pylint_options = [\n",
    "    \"--reports=n\",\n",
    "    \"--output-format=json\",\n",
    "    \"--extension-pkg-allow-list=simulation._csrc._hello\",\n",
    "    \"--prefer-stubs=true\",\n",
    "    \"--clear-cache-post-run=y\",\n",
    "    f\"{root}/python/myproj/simulation/core.py\",  # The file you want to lint\n",
    "]\n",
    "\n",
    "# Create a StringIO buffer to capture Pylint output\n",
    "pylint_output = StringIO()\n",
    "reporter = JSONReporter(output=pylint_output)\n",
    "\n",
    "# Run Pylint\n",
    "pylint.lint.Run(pylint_options, reporter=reporter, exit=True)\n",
    "\n",
    "# Get the output\n",
    "output = pylint_output.getvalue()\n",
    "\n",
    "# Parse and display the results\n",
    "results = json.loads(output)\n",
    "print(json.dumps(results, indent=2))"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "dingxf",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.10.12"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}