mirror of
https://github.com/andreinechaev/nvcc4jupyter.git
synced 2026-06-13 10:40:48 +05:30
Add pylint pre-commit hook
This commit is contained in:
@@ -37,3 +37,10 @@ repos:
|
||||
hooks:
|
||||
- id: flake8
|
||||
args: ["--config", ".flake8"]
|
||||
|
||||
# pylint check
|
||||
- repo: https://github.com/pycqa/pylint
|
||||
rev: v3.0.3
|
||||
hooks:
|
||||
- id: pylint
|
||||
args: ["--rcfile", "pyproject.toml"]
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
"""
|
||||
nvcc4jupyter: CUDA C++ plugin for Jupyter Notebook
|
||||
"""
|
||||
|
||||
from .plugin import NVCCPlugin, load_ipython_extension # noqa: F401
|
||||
|
||||
__version__ = "1.0.2"
|
||||
|
||||
@@ -1,7 +1,14 @@
|
||||
"""
|
||||
Parsers for the CUDA magic commands.
|
||||
"""
|
||||
|
||||
import argparse
|
||||
|
||||
|
||||
def get_parser_cuda() -> argparse.ArgumentParser:
|
||||
"""
|
||||
%%cuda magic command parser.
|
||||
"""
|
||||
parser = argparse.ArgumentParser(
|
||||
description=(
|
||||
"%%cuda magic that compiles and runs CUDA C++ code in this cell."
|
||||
@@ -16,6 +23,9 @@ def get_parser_cuda() -> argparse.ArgumentParser:
|
||||
|
||||
|
||||
def get_parser_cuda_group_run() -> argparse.ArgumentParser:
|
||||
"""
|
||||
%%cuda_group_run magic command parser.
|
||||
"""
|
||||
parser = get_parser_cuda()
|
||||
parser.description = (
|
||||
"%%cuda_group_run magic that compiles and runs source files in a given"
|
||||
@@ -28,6 +38,9 @@ def get_parser_cuda_group_run() -> argparse.ArgumentParser:
|
||||
|
||||
|
||||
def get_parser_cuda_group_save() -> argparse.ArgumentParser:
|
||||
"""
|
||||
%%cuda_group_save magic command parser.
|
||||
"""
|
||||
parser = argparse.ArgumentParser(
|
||||
description=(
|
||||
"%%cuda_group_save magic that saves CUDA C++ code in this cell for"
|
||||
@@ -42,6 +55,9 @@ def get_parser_cuda_group_save() -> argparse.ArgumentParser:
|
||||
|
||||
|
||||
def get_parser_cuda_group_delete() -> argparse.ArgumentParser:
|
||||
"""
|
||||
%%cuda_group_delete magic command parser.
|
||||
"""
|
||||
parser = argparse.ArgumentParser(
|
||||
description=(
|
||||
"%%cuda_group_delete magic that deletes all files in a group. See"
|
||||
|
||||
+15
-2
@@ -1,3 +1,7 @@
|
||||
"""
|
||||
nvcc4jupyter: CUDA C++ plugin for Jupyter Notebook
|
||||
"""
|
||||
|
||||
import argparse
|
||||
import glob
|
||||
import os
|
||||
@@ -7,6 +11,7 @@ import tempfile
|
||||
import uuid
|
||||
from typing import List, Optional
|
||||
|
||||
# pylint: disable=import-error
|
||||
from IPython.core.interactiveshell import InteractiveShell
|
||||
from IPython.core.magic import Magics, cell_magic, line_magic, magics_class
|
||||
|
||||
@@ -17,14 +22,19 @@ SHARED_GROUP_NAME = "shared"
|
||||
|
||||
|
||||
def print_out(out: str):
|
||||
"""Print string line by line."""
|
||||
for line in out.split("\n"):
|
||||
print(line)
|
||||
|
||||
|
||||
@magics_class
|
||||
class NVCCPlugin(Magics):
|
||||
"""
|
||||
CUDA C++ plugin for Jupyter Notebook
|
||||
"""
|
||||
|
||||
def __init__(self, shell: InteractiveShell):
|
||||
super(NVCCPlugin, self).__init__(shell)
|
||||
super().__init__(shell)
|
||||
self.shell: InteractiveShell # type hint not provided by parent class
|
||||
|
||||
self.parser_cuda = parsers.get_parser_cuda()
|
||||
@@ -55,7 +65,7 @@ class NVCCPlugin(Magics):
|
||||
ValueError: If the source name does not have a proper extension.
|
||||
"""
|
||||
_, ext = os.path.splitext(source_name)
|
||||
if ext != ".cu" and ext != ".h":
|
||||
if ext not in (".cu", ".h"):
|
||||
raise ValueError(
|
||||
f'Given source name "{source_name}" must end in ".h" or ".cu".'
|
||||
)
|
||||
@@ -304,5 +314,8 @@ class NVCCPlugin(Magics):
|
||||
|
||||
|
||||
def load_ipython_extension(shell: InteractiveShell):
|
||||
"""
|
||||
Method used by IPython to load the extension.
|
||||
"""
|
||||
nvcc_plugin = NVCCPlugin(shell)
|
||||
shell.register_magics(nvcc_plugin)
|
||||
|
||||
@@ -142,6 +142,7 @@ extension-pkg-whitelist= [
|
||||
]
|
||||
ignore="CVS"
|
||||
ignore-patterns="test.*?py,conftest.py"
|
||||
ignore-paths="docs,tests"
|
||||
init-hook='import sys; sys.setrecursionlimit(8 * sys.getrecursionlimit())'
|
||||
jobs=0
|
||||
limit-inference-results=100
|
||||
|
||||
Reference in New Issue
Block a user