mirror of
https://github.com/hwchase17/langchain.git
synced 2025-09-02 11:39:18 +00:00
ruff: add bugbear across packages (#31917)
WIP, other packages will get in next PRs
This commit is contained in:
@@ -134,19 +134,22 @@ def add(
|
||||
typer.Argument(help="The dependency to add"),
|
||||
] = None,
|
||||
*,
|
||||
api_path: Annotated[list[str], typer.Option(help="API paths to add")] = [],
|
||||
api_path: Annotated[
|
||||
Optional[list[str]],
|
||||
typer.Option(help="API paths to add"),
|
||||
] = None,
|
||||
project_dir: Annotated[
|
||||
Optional[Path],
|
||||
typer.Option(help="The project directory"),
|
||||
] = None,
|
||||
repo: Annotated[
|
||||
list[str],
|
||||
Optional[list[str]],
|
||||
typer.Option(help="Install templates from a specific github repo instead"),
|
||||
] = [],
|
||||
] = None,
|
||||
branch: Annotated[
|
||||
list[str],
|
||||
Optional[list[str]],
|
||||
typer.Option(help="Install templates from a specific branch"),
|
||||
] = [],
|
||||
] = None,
|
||||
pip: Annotated[
|
||||
bool,
|
||||
typer.Option(
|
||||
@@ -163,6 +166,12 @@ def add(
|
||||
langchain app add extraction-openai-functions
|
||||
langchain app add git+ssh://git@github.com/efriis/simple-pirate.git
|
||||
"""
|
||||
if branch is None:
|
||||
branch = []
|
||||
if repo is None:
|
||||
repo = []
|
||||
if api_path is None:
|
||||
api_path = []
|
||||
if not branch and not repo:
|
||||
warnings.warn(
|
||||
"Adding templates from the default branch and repo is deprecated."
|
||||
|
@@ -90,7 +90,7 @@ def new(
|
||||
replacements = _process_name(name)
|
||||
except ValueError as e:
|
||||
typer.echo(e)
|
||||
raise typer.Exit(code=1)
|
||||
raise typer.Exit(code=1) from None
|
||||
|
||||
if name_class:
|
||||
if not re.match(r"^[A-Z][a-zA-Z0-9]*$", name_class):
|
||||
|
@@ -65,7 +65,7 @@ def parse_dependency_string(
|
||||
else:
|
||||
_, post_slash = find_slash.split("/", 1)
|
||||
if "@" in post_slash or "#" in post_slash:
|
||||
_, ref = re.split(r"[@#]", post_slash, 1)
|
||||
_, ref = re.split(r"[@#]", post_slash, maxsplit=1)
|
||||
|
||||
# gitstring is everything before that
|
||||
gitstring = gitstring[: -len(ref) - 1] if ref is not None else gitstring
|
||||
@@ -159,7 +159,7 @@ def _get_repo_path(gitstring: str, ref: Optional[str], repo_dir: Path) -> Path:
|
||||
hashed = hashlib.sha256((f"{gitstring}:{ref_str}").encode()).hexdigest()[:8]
|
||||
|
||||
removed_protocol = gitstring.split("://")[-1]
|
||||
removed_basename = re.split(r"[/:]", removed_protocol, 1)[-1]
|
||||
removed_basename = re.split(r"[/:]", removed_protocol, maxsplit=1)[-1]
|
||||
removed_extras = removed_basename.split("#")[0]
|
||||
foldername = re.sub(r"\W", "_", removed_extras)
|
||||
|
||||
|
@@ -50,6 +50,7 @@ exclude = [
|
||||
[tool.ruff.lint]
|
||||
select = [
|
||||
"A", # flake8-builtins
|
||||
"B", # flake8-bugbear
|
||||
"ARG", # flake8-unused-arguments
|
||||
"ASYNC", # flake8-async
|
||||
"C4", # flake8-comprehensions
|
||||
@@ -96,6 +97,7 @@ ignore = [
|
||||
"D105", # pydocstyle: Missing docstring in magic method
|
||||
"D107", # pydocstyle: Missing docstring in __init__
|
||||
"D407", # pydocstyle: Missing-dashed-underline-after-section
|
||||
"COM812", # Messes with the formatter
|
||||
]
|
||||
pyupgrade.keep-runtime-typing = true
|
||||
|
||||
|
Reference in New Issue
Block a user