├── .editorconfig ├── qa.sh ├── style.bat ├── qa.bat ├── style.sh ├── requirements.txt ├── clean_all.sh ├── README.md ├── .flake8 ├── .isort.cfg ├── run_pylint.py ├── .pre-commit-config.yaml ├── .coveragerc ├── pyproject.toml ├── LICENSE ├── .sourcery.yaml ├── .gitignore ├── src └── auto_gpt_vicuna │ └── __init__.py └── pylintrc /.editorconfig: -------------------------------------------------------------------------------- 1 | [*.py] 2 | profile = black 3 | -------------------------------------------------------------------------------- /qa.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -euf -o pipefail 3 | flake8 . 4 | python run_pylint.py -------------------------------------------------------------------------------- /style.bat: -------------------------------------------------------------------------------- 1 | isort . & black --exclude=".*\/*(dist|venv|.venv|test-results)\/*.*" . -------------------------------------------------------------------------------- /qa.bat: -------------------------------------------------------------------------------- 1 | @call python -m flake8 . || exit \b 1 2 | @call python run_pylint.py || exit \b 1 3 | -------------------------------------------------------------------------------- /style.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | isort . 4 | black --exclude='.*\/*(dist|venv|.venv|test-results)\/*.*' . -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | black 2 | isort 3 | flake8 4 | pylint 5 | abstract-singleton 6 | wheel 7 | setuptools 8 | build 9 | twine 10 | auto-vicuna -------------------------------------------------------------------------------- /clean_all.sh: -------------------------------------------------------------------------------- 1 | rm build -rf 2 | rm dist -rf 3 | rm __pycache__ -rf 4 | rm *.egg-info -rf 5 | rm **/*.egg-info -rf 6 | rm *.pyc -rf 7 | rm **/*.pyc -rf 8 | rm reports -rf -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Auto-GPT-Vicuna Plugin 2 | 3 | Allows chat completions with auto-vicuna. 4 | 5 | See https://github.com/BillSchumacher/Auto-Vicuna for setup details. 6 | 7 | -------------------------------------------------------------------------------- /.flake8: -------------------------------------------------------------------------------- 1 | [flake8] 2 | max-line-length = 88 3 | extend-ignore = E203 4 | exclude = 5 | .tox, 6 | __pycache__, 7 | *.pyc, 8 | .env 9 | venv/* 10 | .venv/* 11 | reports/* 12 | dist/* 13 | -------------------------------------------------------------------------------- /.isort.cfg: -------------------------------------------------------------------------------- 1 | [settings] 2 | profile = black 3 | multi_line_output = 3 4 | include_trailing_comma = True 5 | force_grid_wrap = 0 6 | use_parentheses = True 7 | ensure_newline_before_comments = True 8 | line_length = 88 9 | skip = venv,env,node_modules,.env,.venv,dist 10 | sections = FUTURE,STDLIB,THIRDPARTY,FIRSTPARTY,LOCALFOLDER -------------------------------------------------------------------------------- /run_pylint.py: -------------------------------------------------------------------------------- 1 | """ 2 | https://stackoverflow.com/questions/49100806/ 3 | pylint-and-subprocess-run-returning-exit-status-28 4 | """ 5 | import subprocess 6 | 7 | cmd = " pylint src\\**\\*" 8 | try: 9 | subprocComplete = subprocess.run( 10 | cmd, shell=True, check=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE 11 | ) 12 | print(subprocComplete.stdout.decode("utf-8")) 13 | except subprocess.CalledProcessError as err: 14 | print(err.output.decode("utf-8")) 15 | -------------------------------------------------------------------------------- /.pre-commit-config.yaml: -------------------------------------------------------------------------------- 1 | repos: 2 | - repo: https://github.com/sourcery-ai/sourcery 3 | rev: v1.1.0 # Get the latest tag from https://github.com/sourcery-ai/sourcery/tags 4 | hooks: 5 | - id: sourcery 6 | 7 | - repo: git://github.com/pre-commit/pre-commit-hooks 8 | rev: v0.9.2 9 | hooks: 10 | - id: check-added-large-files 11 | args: [ '--maxkb=500' ] 12 | - id: check-byte-order-marker 13 | - id: check-case-conflict 14 | - id: check-merge-conflict 15 | - id: check-symlinks 16 | - id: debug-statements 17 | 18 | - repo: local 19 | hooks: 20 | - id: isort 21 | name: isort-local 22 | entry: isort 23 | language: python 24 | types: [ python ] 25 | exclude: .+/(dist|.venv|venv|build)/.+ 26 | pass_filenames: true 27 | - id: black 28 | name: black-local 29 | entry: black 30 | language: python 31 | types: [ python ] 32 | exclude: .+/(dist|.venv|venv|build)/.+ 33 | pass_filenames: true -------------------------------------------------------------------------------- /.coveragerc: -------------------------------------------------------------------------------- 1 | [coverage:run] 2 | branch = True 3 | plugins = 4 | omit = 5 | # omit anything in a .local directory anywhere 6 | */.local/* 7 | 8 | [run] 9 | branch = True 10 | plugins = 11 | omit = 12 | # omit anything in a .local directory anywhere 13 | */.local/* 14 | 15 | [paths] 16 | source = . 17 | 18 | 19 | [report] 20 | # Regexes for lines to exclude from consideration 21 | 22 | omit = 23 | # omit anything in a .local directory anywhere 24 | */.local/* 25 | 26 | exclude_lines = 27 | # Have to re-enable the standard pragma 28 | pragma: no cover 29 | # Don't complain about missing debug-only code: 30 | def __repr__ 31 | if self\.debug 32 | 33 | # Don't complain if tests don't hit defensive assertion code: 34 | raise AssertionError 35 | raise NotImplementedError 36 | 37 | # Don't complain if non-runnable code isn't run: 38 | if 0: 39 | if __name__ == .__main__.: 40 | 41 | # Don't complain about abstract methods, they aren't run: 42 | @(abc\.)?abstractmethod 43 | 44 | ignore_errors = True 45 | -------------------------------------------------------------------------------- /pyproject.toml: -------------------------------------------------------------------------------- 1 | [build-system] 2 | requires = ["hatchling"] 3 | build-backend = "hatchling.build" 4 | 5 | [project] 6 | name = "auto_gpt_vicuna" 7 | version = "0.0.1" 8 | authors = [ 9 | { name="Bill Schumacher", email="34168009+BillSchumacher@users.noreply.github.com" }, 10 | ] 11 | description = "The Vicuna for Auto-GPT." 12 | readme = "README.md" 13 | requires-python = ">=3.9" 14 | classifiers = [ 15 | "Programming Language :: Python :: 3", 16 | "License :: OSI Approved :: MIT License", 17 | "Operating System :: OS Independent", 18 | ] 19 | dependencies = ["abstract-singleton", "auto-vicuna", "auto-gpt-plugin-template"] 20 | 21 | [project.urls] 22 | "Homepage" = "https://github.com/BillSchumacher/Auto-GPT-Vicuna" 23 | "Bug Tracker" = "https://github.com/BillSchumacher/Auto-GPT-Vicuna/issues" 24 | 25 | [tool.black] 26 | line-length = 88 27 | target-version = ['py310'] 28 | include = '\.pyi?$' 29 | extend-exclude = "" 30 | 31 | [tool.isort] 32 | profile = "black" 33 | 34 | [tool.pylint.messages_control] 35 | disable = "C0330, C0326" 36 | 37 | [tool.pylint.format] 38 | max-line-length = "88" -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 Toran Bruce Richards 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /.sourcery.yaml: -------------------------------------------------------------------------------- 1 | # 🪄 This is your project's Sourcery configuration file. 2 | 3 | # You can use it to get Sourcery working in the way you want, such as 4 | # ignoring specific refactorings, skipping directories in your project, 5 | # or writing custom rules. 6 | 7 | # 📚 For a complete reference to this file, see the documentation at 8 | # https://docs.sourcery.ai/Configuration/Project-Settings/ 9 | 10 | # This file was auto-generated by Sourcery on 2023-02-25 at 21:07. 11 | 12 | version: '1' # The schema version of this config file 13 | 14 | ignore: # A list of paths or files which Sourcery will ignore. 15 | - .git 16 | - venv 17 | - .venv 18 | - build 19 | - dist 20 | - env 21 | - .env 22 | - .tox 23 | 24 | rule_settings: 25 | enable: 26 | - default 27 | - gpsg 28 | disable: [] # A list of rule IDs Sourcery will never suggest. 29 | rule_types: 30 | - refactoring 31 | - suggestion 32 | - comment 33 | python_version: '3.9' # A string specifying the lowest Python version your project supports. Sourcery will not suggest refactorings requiring a higher Python version. 34 | 35 | # rules: # A list of custom rules Sourcery will include in its analysis. 36 | # - id: no-print-statements 37 | # description: Do not use print statements in the test directory. 38 | # pattern: print(...) 39 | # language: python 40 | # replacement: 41 | # condition: 42 | # explanation: 43 | # paths: 44 | # include: 45 | # - test 46 | # exclude: 47 | # - conftest.py 48 | # tests: [] 49 | # tags: [] 50 | 51 | # rule_tags: {} # Additional rule tags. 52 | 53 | # metrics: 54 | # quality_threshold: 25.0 55 | 56 | # github: 57 | # labels: [] 58 | # ignore_labels: 59 | # - sourcery-ignore 60 | # request_review: author 61 | # sourcery_branch: sourcery/{base_branch} 62 | 63 | # clone_detection: 64 | # min_lines: 3 65 | # min_duplicates: 2 66 | # identical_clones_only: false 67 | 68 | # proxy: 69 | # url: 70 | # ssl_certs_file: 71 | # no_ssl_verify: false 72 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | build/ 12 | develop-eggs/ 13 | dist/ 14 | downloads/ 15 | eggs/ 16 | .eggs/ 17 | lib/ 18 | lib64/ 19 | parts/ 20 | sdist/ 21 | var/ 22 | wheels/ 23 | pip-wheel-metadata/ 24 | share/python-wheels/ 25 | *.egg-info/ 26 | .installed.cfg 27 | *.egg 28 | MANIFEST 29 | 30 | # PyInstaller 31 | # Usually these files are written by a python script from a template 32 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 33 | *.manifest 34 | *.spec 35 | 36 | # Installer logs 37 | pip-log.txt 38 | pip-delete-this-directory.txt 39 | 40 | # Unit test / coverage reports 41 | htmlcov/ 42 | .tox/ 43 | .nox/ 44 | .coverage 45 | .coverage.* 46 | .cache 47 | nosetests.xml 48 | coverage.xml 49 | *.cover 50 | *.py,cover 51 | .hypothesis/ 52 | .pytest_cache/ 53 | 54 | # Translations 55 | *.mo 56 | *.pot 57 | 58 | # Django stuff: 59 | *.log 60 | local_settings.py 61 | db.sqlite3 62 | db.sqlite3-journal 63 | 64 | # Flask stuff: 65 | instance/ 66 | .webassets-cache 67 | 68 | # Scrapy stuff: 69 | .scrapy 70 | 71 | # Sphinx documentation 72 | docs/_build/ 73 | 74 | # PyBuilder 75 | target/ 76 | 77 | # Jupyter Notebook 78 | .ipynb_checkpoints 79 | 80 | # IPython 81 | profile_default/ 82 | ipython_config.py 83 | 84 | # pyenv 85 | .python-version 86 | 87 | # pipenv 88 | # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. 89 | # However, in case of collaboration, if having platform-specific dependencies or dependencies 90 | # having no cross-platform support, pipenv may install dependencies that don't work, or not 91 | # install all needed dependencies. 92 | #Pipfile.lock 93 | 94 | # PEP 582; used by e.g. github.com/David-OConnor/pyflow 95 | __pypackages__/ 96 | 97 | # Celery stuff 98 | celerybeat-schedule 99 | celerybeat.pid 100 | 101 | # SageMath parsed files 102 | *.sage.py 103 | 104 | # Environments 105 | .env 106 | .venv 107 | env/ 108 | venv/ 109 | ENV/ 110 | env.bak/ 111 | venv.bak/ 112 | 113 | # Spyder project settings 114 | .spyderproject 115 | .spyproject 116 | 117 | # Rope project settings 118 | .ropeproject 119 | 120 | # mkdocs documentation 121 | /site 122 | 123 | # mypy 124 | .mypy_cache/ 125 | .dmypy.json 126 | dmypy.json 127 | 128 | # Pyre type checker 129 | .pyre/ 130 | -------------------------------------------------------------------------------- /src/auto_gpt_vicuna/__init__.py: -------------------------------------------------------------------------------- 1 | """This is the Vicuna plugin for Auto-GPT.""" 2 | import os 3 | from pathlib import Path 4 | from typing import Any, Dict, List, Optional, Tuple, TypeVar 5 | 6 | from auto_vicuna.__main__ import load_model 7 | from auto_vicuna.chat import chat_one_shot 8 | from auto_vicuna.conversation import make_conversation 9 | from auto_gpt_plugin_template import AutoGPTPluginTemplate 10 | 11 | import torch 12 | 13 | PromptGenerator = TypeVar("PromptGenerator") 14 | 15 | 16 | class AutoGPTPVicuna(AutoGPTPluginTemplate): 17 | """ 18 | This is the Vicuna local model plugin for Auto-GPT. 19 | """ 20 | 21 | def __init__(self): 22 | super().__init__() 23 | self._name = "Auto-GPT-Vicuna" 24 | self._version = "0.1.0" 25 | self._description = "This is a Vicuna local model plugin." 26 | self.device = "cuda" if torch.cuda.is_available() else "cpu" 27 | self.vicuna_weights = os.environ.get("VICUNA_WEIGHTS", "") 28 | self.load_8bit = os.environ.get("LOAD_8BIT", False) 29 | 30 | model, tokenizer = load_model( 31 | self.vicuna_weights, 32 | device=self.device, 33 | num_gpus=1, 34 | debug=False, 35 | load_8bit=self.load_8bit, 36 | ) 37 | self.model = model 38 | self.tokenizer = tokenizer 39 | 40 | model.eval() 41 | 42 | def can_handle_on_response(self) -> bool: 43 | """This method is called to check that the plugin can 44 | handle the on_response method. 45 | 46 | Returns: 47 | bool: True if the plugin can handle the on_response method.""" 48 | return False 49 | 50 | def on_response(self, response: str, *args, **kwargs) -> str: 51 | """This method is called when a response is received from the model.""" 52 | pass 53 | 54 | def can_handle_post_prompt(self) -> bool: 55 | """This method is called to check that the plugin can 56 | handle the post_prompt method. 57 | 58 | Returns: 59 | bool: True if the plugin can handle the post_prompt method.""" 60 | return False 61 | 62 | def post_prompt(self, prompt: PromptGenerator) -> PromptGenerator: 63 | """This method is called just after the generate_prompt is called, 64 | but actually before the prompt is generated. 65 | 66 | Args: 67 | prompt (PromptGenerator): The prompt generator. 68 | 69 | Returns: 70 | PromptGenerator: The prompt generator. 71 | """ 72 | pass 73 | 74 | def can_handle_on_planning(self) -> bool: 75 | """This method is called to check that the plugin can 76 | handle the on_planning method. 77 | 78 | Returns: 79 | bool: True if the plugin can handle the on_planning method.""" 80 | return False 81 | 82 | def on_planning( 83 | self, prompt: PromptGenerator, messages: List[str] 84 | ) -> Optional[str]: 85 | """This method is called before the planning chat completeion is done. 86 | 87 | Args: 88 | prompt (PromptGenerator): The prompt generator. 89 | messages (List[str]): The list of messages. 90 | """ 91 | pass 92 | 93 | def can_handle_post_planning(self) -> bool: 94 | """This method is called to check that the plugin can 95 | handle the post_planning method. 96 | 97 | Returns: 98 | bool: True if the plugin can handle the post_planning method.""" 99 | return False 100 | 101 | def post_planning(self, response: str) -> str: 102 | """This method is called after the planning chat completeion is done. 103 | 104 | Args: 105 | response (str): The response. 106 | 107 | Returns: 108 | str: The resulting response. 109 | """ 110 | pass 111 | 112 | def can_handle_pre_instruction(self) -> bool: 113 | """This method is called to check that the plugin can 114 | handle the pre_instruction method. 115 | 116 | Returns: 117 | bool: True if the plugin can handle the pre_instruction method.""" 118 | return False 119 | 120 | def pre_instruction(self, messages: List[str]) -> List[str]: 121 | """This method is called before the instruction chat is done. 122 | 123 | Args: 124 | messages (List[str]): The list of context messages. 125 | 126 | Returns: 127 | List[str]: The resulting list of messages. 128 | """ 129 | pass 130 | 131 | def can_handle_on_instruction(self) -> bool: 132 | """This method is called to check that the plugin can 133 | handle the on_instruction method. 134 | 135 | Returns: 136 | bool: True if the plugin can handle the on_instruction method.""" 137 | return False 138 | 139 | def on_instruction(self, messages: List[str]) -> Optional[str]: 140 | """This method is called when the instruction chat is done. 141 | 142 | Args: 143 | messages (List[str]): The list of context messages. 144 | 145 | Returns: 146 | Optional[str]: The resulting message. 147 | """ 148 | pass 149 | 150 | def can_handle_post_instruction(self) -> bool: 151 | """This method is called to check that the plugin can 152 | handle the post_instruction method. 153 | 154 | Returns: 155 | bool: True if the plugin can handle the post_instruction method.""" 156 | return False 157 | 158 | def post_instruction(self, response: str) -> str: 159 | """This method is called after the instruction chat is done. 160 | 161 | Args: 162 | response (str): The response. 163 | 164 | Returns: 165 | str: The resulting response. 166 | """ 167 | pass 168 | 169 | def can_handle_pre_command(self) -> bool: 170 | """This method is called to check that the plugin can 171 | handle the pre_command method. 172 | 173 | Returns: 174 | bool: True if the plugin can handle the pre_command method.""" 175 | return False 176 | 177 | def pre_command( 178 | self, command_name: str, arguments: Dict[str, Any] 179 | ) -> Tuple[str, Dict[str, Any]]: 180 | """This method is called before the command is executed. 181 | 182 | Args: 183 | command_name (str): The command name. 184 | arguments (Dict[str, Any]): The arguments. 185 | 186 | Returns: 187 | Tuple[str, Dict[str, Any]]: The command name and the arguments. 188 | """ 189 | pass 190 | 191 | def can_handle_post_command(self) -> bool: 192 | """This method is called to check that the plugin can 193 | handle the post_command method. 194 | 195 | Returns: 196 | bool: True if the plugin can handle the post_command method.""" 197 | return False 198 | 199 | def post_command(self, command_name: str, response: str) -> str: 200 | """This method is called after the command is executed. 201 | 202 | Args: 203 | command_name (str): The command name. 204 | response (str): The response. 205 | 206 | Returns: 207 | str: The resulting response. 208 | """ 209 | pass 210 | 211 | def can_handle_chat_completion( 212 | self, 213 | messages: list[Dict[Any, Any]], 214 | model: str, 215 | temperature: float, 216 | max_tokens: int, 217 | ) -> bool: 218 | """This method is called to check that the plugin can 219 | handle the chat_completion method. 220 | 221 | Args: 222 | messages (Dict[Any, Any]): The messages. 223 | model (str): The model name. 224 | temperature (float): The temperature. 225 | max_tokens (int): The max tokens. 226 | 227 | Returns: 228 | bool: True if the plugin can handle the chat_completion method.""" 229 | return True 230 | 231 | def handle_chat_completion( 232 | self, 233 | messages: list[Dict[Any, Any]], 234 | model: str, 235 | temperature: float, 236 | max_tokens: int, 237 | ) -> str: 238 | """This method is called when the chat completion is done. 239 | 240 | Args: 241 | messages (Dict[Any, Any]): The messages. 242 | model (str): The model name. 243 | temperature (float): The temperature. 244 | max_tokens (int): The max tokens. 245 | 246 | Returns: 247 | str: The resulting response. 248 | """ 249 | roles = {message["role"] for message in messages} 250 | last_message = messages.pop()["content"] 251 | conv = make_conversation( 252 | "", 253 | list(roles), 254 | [(message["role"], message["content"]) for message in messages], 255 | ) 256 | if max_tokens is None: 257 | max_tokens = 2048 258 | max_tokens = min(max_tokens, 2048) 259 | with torch.inference_mode(): 260 | return chat_one_shot( 261 | self.model, 262 | self.tokenizer, 263 | self.vicuna_weights, 264 | self.device, 265 | conv, 266 | last_message, 267 | temperature, 268 | max_tokens, 269 | ) 270 | -------------------------------------------------------------------------------- /pylintrc: -------------------------------------------------------------------------------- 1 | # This Pylint rcfile contains a best-effort configuration to uphold the 2 | # best-practices and style described in the Google Python style guide: 3 | # https://google.github.io/styleguide/pyguide.html 4 | # 5 | # Its canonical open-source location is: 6 | # https://google.github.io/styleguide/pylintrc 7 | 8 | [MASTER] 9 | 10 | # Files or directories to be skipped. They should be base names, not paths. 11 | ignore= 12 | 13 | # Files or directories matching the regex patterns are skipped. The regex 14 | # matches against base names, not paths. 15 | ignore-patterns= 16 | 17 | # Pickle collected data for later comparisons. 18 | persistent=no 19 | 20 | # List of plugins (as comma separated values of python modules names) to load, 21 | # usually to register additional checkers. 22 | load-plugins= 23 | 24 | # Use multiple processes to speed up Pylint. 25 | jobs=4 26 | 27 | # Allow loading of arbitrary C extensions. Extensions are imported into the 28 | # active Python interpreter and may run arbitrary code. 29 | unsafe-load-any-extension=no 30 | 31 | 32 | [MESSAGES CONTROL] 33 | 34 | ignore=*.pyc 35 | # Only show warnings with the listed confidence levels. Leave empty to show 36 | # all. Valid levels: HIGH, INFERENCE, INFERENCE_FAILURE, UNDEFINED 37 | confidence= 38 | 39 | # Enable the message, report, category or checker with the given id(s). You can 40 | # either give multiple identifier separated by comma (,) or put this option 41 | # multiple time (only on the command line, not in the configuration file where 42 | # it should appear only once). See also the "--disable" option for examples. 43 | #enable= 44 | 45 | # Disable the message, report, category or checker with the given id(s). You 46 | # can either give multiple identifiers separated by comma (,) or put this 47 | # option multiple times (only on the command line, not in the configuration 48 | # file where it should appear only once).You can also use "--disable=all" to 49 | # disable everything first and then reenable specific checks. For example, if 50 | # you want to run only the similarities checker, you can use "--disable=all 51 | # --enable=similarities". If you want to run only the classes checker, but have 52 | # no Warning level messages displayed, use"--disable=all --enable=classes 53 | # --disable=W" 54 | disable=abstract-method, 55 | parse-error, 56 | apply-builtin, 57 | arguments-differ, 58 | attribute-defined-outside-init, 59 | backtick, 60 | bad-option-value, 61 | basestring-builtin, 62 | buffer-builtin, 63 | c-extension-no-member, 64 | consider-using-enumerate, 65 | cmp-builtin, 66 | cmp-method, 67 | coerce-builtin, 68 | coerce-method, 69 | delslice-method, 70 | div-method, 71 | duplicate-code, 72 | eq-without-hash, 73 | execfile-builtin, 74 | file-builtin, 75 | filter-builtin-not-iterating, 76 | fixme, 77 | getslice-method, 78 | global-statement, 79 | hex-method, 80 | idiv-method, 81 | implicit-str-concat, 82 | import-error, 83 | import-self, 84 | import-star-module-level, 85 | inconsistent-return-statements, 86 | input-builtin, 87 | intern-builtin, 88 | invalid-str-codec, 89 | locally-disabled, 90 | long-builtin, 91 | long-suffix, 92 | map-builtin-not-iterating, 93 | misplaced-comparison-constant, 94 | missing-function-docstring, 95 | metaclass-assignment, 96 | next-method-called, 97 | next-method-defined, 98 | no-absolute-import, 99 | no-else-break, 100 | no-else-continue, 101 | no-else-raise, 102 | no-else-return, 103 | no-init, # added 104 | no-member, 105 | no-name-in-module, 106 | no-self-use, 107 | nonzero-method, 108 | oct-method, 109 | old-division, 110 | old-ne-operator, 111 | old-octal-literal, 112 | old-raise-syntax, 113 | parameter-unpacking, 114 | print-statement, 115 | raising-string, 116 | range-builtin-not-iterating, 117 | raw_input-builtin, 118 | rdiv-method, 119 | reduce-builtin, 120 | relative-import, 121 | reload-builtin, 122 | round-builtin, 123 | setslice-method, 124 | signature-differs, 125 | standarderror-builtin, 126 | suppressed-message, 127 | sys-max-int, 128 | too-few-public-methods, 129 | too-many-ancestors, 130 | too-many-arguments, 131 | too-many-boolean-expressions, 132 | too-many-branches, 133 | too-many-instance-attributes, 134 | too-many-locals, 135 | too-many-nested-blocks, 136 | too-many-public-methods, 137 | too-many-return-statements, 138 | too-many-statements, 139 | trailing-newlines, 140 | unichr-builtin, 141 | unicode-builtin, 142 | unnecessary-pass, 143 | unpacking-in-except, 144 | useless-else-on-loop, 145 | useless-object-inheritance, 146 | useless-suppression, 147 | using-cmp-argument, 148 | wrong-import-order, 149 | xrange-builtin, 150 | zip-builtin-not-iterating, 151 | 152 | 153 | [REPORTS] 154 | 155 | # Set the output format. Available formats are text, parseable, colorized, msvs 156 | # (visual studio) and html. You can also give a reporter class, eg 157 | # mypackage.mymodule.MyReporterClass. 158 | output-format=text 159 | 160 | # Tells whether to display a full report or only the messages 161 | reports=no 162 | 163 | # Python expression which should return a note less than 10 (10 is the highest 164 | # note). You have access to the variables errors warning, statement which 165 | # respectively contain the number of errors / warnings messages and the total 166 | # number of statements analyzed. This is used by the global evaluation report 167 | # (RP0004). 168 | evaluation=10.0 - ((float(5 * error + warning + refactor + convention) / statement) * 10) 169 | 170 | # Template used to display messages. This is a python new-style format string 171 | # used to format the message information. See doc for all details 172 | #msg-template= 173 | 174 | 175 | [BASIC] 176 | 177 | # Good variable names which should always be accepted, separated by a comma 178 | good-names=main,_ 179 | 180 | # Bad variable names which should always be refused, separated by a comma 181 | bad-names= 182 | 183 | # Colon-delimited sets of names that determine each other's naming style when 184 | # the name regexes allow several styles. 185 | name-group= 186 | 187 | # Include a hint for the correct naming format with invalid-name 188 | include-naming-hint=no 189 | 190 | # List of decorators that produce properties, such as abc.abstractproperty. Add 191 | # to this list to register other decorators that produce valid properties. 192 | property-classes=abc.abstractproperty,cached_property.cached_property,cached_property.threaded_cached_property,cached_property.cached_property_with_ttl,cached_property.threaded_cached_property_with_ttl 193 | 194 | # Regular expression matching correct function names 195 | function-rgx=^(?:(?PsetUp|tearDown|setUpModule|tearDownModule)|(?P_?[A-Z][a-zA-Z0-9]*)|(?P_?[a-z][a-z0-9_]*))$ 196 | 197 | # Regular expression matching correct variable names 198 | variable-rgx=^[a-z][a-z0-9_]*$ 199 | 200 | # Regular expression matching correct constant names 201 | const-rgx=^(_?[A-Z][A-Z0-9_]*|__[a-z0-9_]+__|_?[a-z][a-z0-9_]*)$ 202 | 203 | # Regular expression matching correct attribute names 204 | attr-rgx=^_{0,2}[a-z][a-z0-9_]*$ 205 | 206 | # Regular expression matching correct argument names 207 | argument-rgx=^[a-z][a-z0-9_]*$ 208 | 209 | # Regular expression matching correct class attribute names 210 | class-attribute-rgx=^(_?[A-Z][A-Z0-9_]*|__[a-z0-9_]+__|_?[a-z][a-z0-9_]*)$ 211 | 212 | # Regular expression matching correct inline iteration names 213 | inlinevar-rgx=^[a-z][a-z0-9_]*$ 214 | 215 | # Regular expression matching correct class names 216 | class-rgx=^_?[A-Z][a-zA-Z0-9]*$ 217 | 218 | # Regular expression matching correct module names 219 | module-rgx=^(_?[a-z][a-z0-9_]*|__init__|__main__)$ 220 | 221 | # Regular expression matching correct method names 222 | method-rgx=(?x)^(?:(?P_[a-z0-9_]+__|runTest|setUp|tearDown|setUpTestCase|tearDownTestCase|setupSelf|tearDownClass|setUpClass|(test|assert)_*[A-Z0-9][a-zA-Z0-9_]*|next)|(?P_{0,2}[A-Z][a-zA-Z0-9_]*)|(?P_{0,2}[a-z][a-z0-9_]*))$ 223 | 224 | # Regular expression which should only match function or class names that do 225 | # not require a docstring. 226 | no-docstring-rgx=(__.*__|main|test.*|.*test|.*Test)$ 227 | 228 | # Minimum line length for functions/classes that require docstrings, shorter 229 | # ones are exempt. 230 | docstring-min-length=10 231 | 232 | 233 | [TYPECHECK] 234 | 235 | # List of decorators that produce context managers, such as 236 | # contextlib.contextmanager. Add to this list to register other decorators that 237 | # produce valid context managers. 238 | contextmanager-decorators=contextlib.contextmanager,contextlib2.contextmanager 239 | 240 | # Tells whether missing members accessed in mixin class should be ignored. A 241 | # mixin class is detected if its name ends with "mixin" (case insensitive). 242 | ignore-mixin-members=yes 243 | 244 | # List of module names for which member attributes should not be checked 245 | # (useful for modules/projects where namespaces are manipulated during runtime 246 | # and thus existing member attributes cannot be deduced by static analysis. It 247 | # supports qualified module names, as well as Unix pattern matching. 248 | ignored-modules= 249 | 250 | # List of class names for which member attributes should not be checked (useful 251 | # for classes with dynamically set attributes). This supports the use of 252 | # qualified names. 253 | ignored-classes=optparse.Values,thread._local,_thread._local 254 | 255 | # List of members which are set dynamically and missed by pylint inference 256 | # system, and so shouldn't trigger E1101 when accessed. Python regular 257 | # expressions are accepted. 258 | generated-members= 259 | 260 | 261 | [FORMAT] 262 | 263 | # Maximum number of characters on a single line. 264 | max-line-length=88 265 | 266 | # TODO(https://github.com/PyCQA/pylint/issues/3352): Direct pylint to exempt 267 | # lines made too long by directives to pytype. 268 | 269 | # Regexp for a line that is allowed to be longer than the limit. 270 | ignore-long-lines=(?x)( 271 | ^\s*(\#\ )??$| 272 | ^\s*(from\s+\S+\s+)?import\s+.+$) 273 | 274 | # Allow the body of an if to be on the same line as the test if there is no 275 | # else. 276 | single-line-if-stmt=yes 277 | 278 | # Maximum number of lines in a module 279 | max-module-lines=99999 280 | 281 | # String used as indentation unit. The internal Google style guide mandates 2 282 | # spaces. Google's externaly-published style guide says 4, consistent with 283 | # PEP 8. Here, we use 2 spaces, for conformity with many open-sourced Google 284 | # projects (like TensorFlow). 285 | indent-string=' ' 286 | 287 | # Number of spaces of indent required inside a hanging or continued line. 288 | indent-after-paren=4 289 | 290 | # Expected format of line ending, e.g. empty (any line ending), LF or CRLF. 291 | expected-line-ending-format= 292 | 293 | 294 | [MISCELLANEOUS] 295 | 296 | # List of note tags to take in consideration, separated by a comma. 297 | notes=TODO 298 | 299 | 300 | [STRING] 301 | 302 | # This flag controls whether inconsistent-quotes generates a warning when the 303 | # character used as a quote delimiter is used inconsistently within a module. 304 | check-quote-consistency=yes 305 | 306 | 307 | [VARIABLES] 308 | 309 | # Tells whether we should check for unused import in __init__ files. 310 | init-import=no 311 | 312 | # A regular expression matching the name of dummy variables (i.e. expectedly 313 | # not used). 314 | dummy-variables-rgx=^\*{0,2}(_$|unused_|dummy_) 315 | 316 | # List of additional names supposed to be defined in builtins. Remember that 317 | # you should avoid to define new builtins when possible. 318 | additional-builtins= 319 | 320 | # List of strings which can identify a callback function by name. A callback 321 | # name must start or end with one of those strings. 322 | callbacks=cb_,_cb 323 | 324 | # List of qualified module names which can have objects that can redefine 325 | # builtins. 326 | redefining-builtins-modules=six,six.moves,past.builtins,future.builtins,functools 327 | 328 | 329 | [LOGGING] 330 | 331 | # Logging modules to check that the string format arguments are in logging 332 | # function parameter format 333 | logging-modules=logging,absl.logging,tensorflow.io.logging 334 | 335 | 336 | [SIMILARITIES] 337 | 338 | # Minimum lines number of a similarity. 339 | min-similarity-lines=4 340 | 341 | # Ignore comments when computing similarities. 342 | ignore-comments=yes 343 | 344 | # Ignore docstrings when computing similarities. 345 | ignore-docstrings=yes 346 | 347 | # Ignore imports when computing similarities. 348 | ignore-imports=no 349 | 350 | 351 | [SPELLING] 352 | 353 | # Spelling dictionary name. Available dictionaries: none. To make it working 354 | # install python-enchant package. 355 | spelling-dict= 356 | 357 | # List of comma separated words that should not be checked. 358 | spelling-ignore-words= 359 | 360 | # A path to a file that contains private dictionary; one word per line. 361 | spelling-private-dict-file= 362 | 363 | # Tells whether to store unknown words to indicated private dictionary in 364 | # --spelling-private-dict-file option instead of raising a message. 365 | spelling-store-unknown-words=no 366 | 367 | 368 | [IMPORTS] 369 | 370 | # Deprecated modules which should not be used, separated by a comma 371 | deprecated-modules=regsub, 372 | TERMIOS, 373 | Bastion, 374 | rexec, 375 | sets 376 | 377 | # Create a graph of every (i.e. internal and external) dependencies in the 378 | # given file (report RP0402 must not be disabled) 379 | import-graph= 380 | 381 | # Create a graph of external dependencies in the given file (report RP0402 must 382 | # not be disabled) 383 | ext-import-graph= 384 | 385 | # Create a graph of internal dependencies in the given file (report RP0402 must 386 | # not be disabled) 387 | int-import-graph= 388 | 389 | # Force import order to recognize a module as part of the standard 390 | # compatibility libraries. 391 | known-standard-library= 392 | 393 | # Force import order to recognize a module as part of a third party library. 394 | known-third-party=enchant, absl 395 | 396 | # Analyse import fallback blocks. This can be used to support both Python 2 and 397 | # 3 compatible code, which means that the block might have code that exists 398 | # only in one or another interpreter, leading to false positives when analysed. 399 | analyse-fallback-blocks=no 400 | 401 | 402 | [CLASSES] 403 | 404 | # List of method names used to declare (i.e. assign) instance attributes. 405 | defining-attr-methods=__init__, 406 | __new__, 407 | setUp 408 | 409 | # List of member names, which should be excluded from the protected access 410 | # warning. 411 | exclude-protected=_asdict, 412 | _fields, 413 | _replace, 414 | _source, 415 | _make 416 | 417 | # List of valid names for the first argument in a class method. 418 | valid-classmethod-first-arg=cls, 419 | class_ 420 | 421 | # List of valid names for the first argument in a metaclass class method. 422 | valid-metaclass-classmethod-first-arg=mcs 423 | 424 | 425 | [EXCEPTIONS] 426 | 427 | # Exceptions that will emit a warning when being caught. Defaults to 428 | # "Exception" 429 | overgeneral-exceptions=builtins.StandardError, 430 | builtins.Exception, 431 | builtins.BaseException 432 | --------------------------------------------------------------------------------