Skip to content

Commit

Permalink
Merge branch 'main' into dataclasses/inheritance
Browse files Browse the repository at this point in the history
  • Loading branch information
Pierre-Sassoulas committed Dec 26, 2022
2 parents 1756eae + 8dd0adc commit 8a2eb84
Show file tree
Hide file tree
Showing 24 changed files with 138 additions and 69 deletions.
29 changes: 29 additions & 0 deletions .github/workflows/backport.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Backport
on:
pull_request_target:
types:
- closed
- labeled

permissions:
pull-requests: write
contents: write

jobs:
backport:
name: Backport
runs-on: ubuntu-latest
# Only react to merged PRs for security reasons.
# See https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request_target.
if: >
github.event.pull_request.merged && (
github.event.action == 'closed'
|| (
github.event.action == 'labeled'
&& contains(github.event.label.name, 'backport')
)
)
steps:
- uses: tibdex/backport@2e217641d82d02ba0603f46b1aeedefb258890ac # v2.0.3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
34 changes: 17 additions & 17 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:
pull_request: ~

env:
CACHE_VERSION: 2
CACHE_VERSION: 3
KEY_PREFIX: venv
DEFAULT_PYTHON: "3.10"
PRE_COMMIT_CACHE: ~/.cache/pre-commit
Expand All @@ -20,10 +20,10 @@ jobs:
timeout-minutes: 20
steps:
- name: Check out code from GitHub
uses: actions/checkout@v3.1.0
uses: actions/checkout@v3.2.0
- name: Set up Python ${{ env.DEFAULT_PYTHON }}
id: python
uses: actions/setup-python@v4.3.0
uses: actions/setup-python@v4.4.0
with:
python-version: ${{ env.DEFAULT_PYTHON }}
check-latest: true
Expand All @@ -36,7 +36,7 @@ jobs:
'requirements_test_pre_commit.txt') }}" >> $GITHUB_OUTPUT
- name: Restore Python virtual environment
id: cache-venv
uses: actions/cache@v3.0.11
uses: actions/cache@v3.2.1
with:
path: venv
key: >-
Expand All @@ -56,7 +56,7 @@ jobs:
hashFiles('.pre-commit-config.yaml') }}" >> $GITHUB_OUTPUT
- name: Restore pre-commit environment
id: cache-precommit
uses: actions/cache@v3.0.11
uses: actions/cache@v3.2.1
with:
path: ${{ env.PRE_COMMIT_CACHE }}
key: >-
Expand All @@ -83,10 +83,10 @@ jobs:
python-key: ${{ steps.generate-python-key.outputs.key }}
steps:
- name: Check out code from GitHub
uses: actions/checkout@v3.1.0
uses: actions/checkout@v3.2.0
- name: Set up Python ${{ matrix.python-version }}
id: python
uses: actions/setup-python@v4.3.0
uses: actions/setup-python@v4.4.0
with:
python-version: ${{ matrix.python-version }}
check-latest: true
Expand All @@ -103,7 +103,7 @@ jobs:
$GITHUB_OUTPUT
- name: Restore Python virtual environment
id: cache-venv
uses: actions/cache@v3.0.11
uses: actions/cache@v3.2.1
with:
path: venv
key: >-
Expand Down Expand Up @@ -139,16 +139,16 @@ jobs:
COVERAGERC_FILE: .coveragerc
steps:
- name: Check out code from GitHub
uses: actions/checkout@v3.1.0
uses: actions/checkout@v3.2.0
- name: Set up Python ${{ matrix.python-version }}
id: python
uses: actions/setup-python@v4.3.0
uses: actions/setup-python@v4.4.0
with:
python-version: ${{ matrix.python-version }}
check-latest: true
- name: Restore Python virtual environment
id: cache-venv
uses: actions/cache@v3.0.11
uses: actions/cache@v3.2.1
with:
path: venv
key:
Expand Down Expand Up @@ -188,10 +188,10 @@ jobs:
# Workaround to set correct temp directory on Windows
# https://github.com/actions/virtual-environments/issues/712
- name: Check out code from GitHub
uses: actions/checkout@v3.1.0
uses: actions/checkout@v3.2.0
- name: Set up Python ${{ matrix.python-version }}
id: python
uses: actions/setup-python@v4.3.0
uses: actions/setup-python@v4.4.0
with:
python-version: ${{ matrix.python-version }}
check-latest: true
Expand All @@ -203,7 +203,7 @@ jobs:
'requirements_test_brain.txt') }}" >> $env:GITHUB_OUTPUT
- name: Restore Python virtual environment
id: cache-venv
uses: actions/cache@v3.0.11
uses: actions/cache@v3.2.1
with:
path: venv
key: >-
Expand Down Expand Up @@ -232,10 +232,10 @@ jobs:
python-version: ["pypy3.7", "pypy3.8", "pypy3.9"]
steps:
- name: Check out code from GitHub
uses: actions/checkout@v3.1.0
uses: actions/checkout@v3.2.0
- name: Set up Python ${{ matrix.python-version }}
id: python
uses: actions/setup-python@v4.3.0
uses: actions/setup-python@v4.4.0
with:
python-version: ${{ matrix.python-version }}
check-latest: true
Expand All @@ -247,7 +247,7 @@ jobs:
}}" >> $GITHUB_OUTPUT
- name: Restore Python virtual environment
id: cache-venv
uses: actions/cache@v3.0.11
uses: actions/cache@v3.2.1
with:
path: venv
key: >-
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v3.1.0
uses: actions/checkout@v3.2.0

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ jobs:
timeout-minutes: 5
steps:
- name: Check out code from GitHub
uses: actions/checkout@v3.1.0
uses: actions/checkout@v3.2.0
- name: Set up Python 3.9
id: python
uses: actions/setup-python@v4.3.0
uses: actions/setup-python@v4.4.0
with:
# virtualenv 15.1.0 cannot be installed on Python 3.10+
python-version: 3.9
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ jobs:
url: https://pypi.org/project/astroid/
steps:
- name: Check out code from Github
uses: actions/checkout@v3.1.0
uses: actions/checkout@v3.2.0
- name: Set up Python ${{ env.DEFAULT_PYTHON }}
id: python
uses: actions/setup-python@v4.3.0
uses: actions/setup-python@v4.4.0
with:
python-version: ${{ env.DEFAULT_PYTHON }}
check-latest: true
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ repos:
- id: black-disable-checker
exclude: tests/unittest_nodes_lineno.py
- repo: https://github.com/psf/black
rev: 22.10.0
rev: 22.12.0
hooks:
- id: black
args: [--safe, --quiet]
Expand Down
8 changes: 8 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,14 @@ Release date: TBA

Closes PyCQA/pylint#7291

* Fix crash if ``numpy`` module doesn't have ``version`` attribute.

Refs PyCQA/pylint#7868

* Handle ``AttributeError`` during ``str.format`` template inference tip evaluation

Closes PyCQA/pylint#1902


What's New in astroid 2.12.13?
==============================
Expand Down
2 changes: 2 additions & 0 deletions astroid/_ast.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import ast
import sys
import types
from collections.abc import Callable
from functools import partial
from typing import NamedTuple

Expand Down Expand Up @@ -36,6 +37,7 @@ class ParserModule(NamedTuple):
context_classes: dict[type[ast.expr_context], Context]

def parse(self, string: str, type_comments: bool = True) -> ast.Module:
parse_func: Callable[[str], ast.Module]
if self.module is _ast_py3:
if PY38_PLUS:
parse_func = partial(self.module.parse, type_comments=type_comments)
Expand Down
5 changes: 3 additions & 2 deletions astroid/brain/brain_builtin_inference.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ def _builtin_filter_predicate(node, builtin_name) -> bool:
return False


def register_builtin_transform(transform, builtin_name):
def register_builtin_transform(transform, builtin_name) -> None:
"""Register a new transform function for the given *builtin_name*.
The transform function must accept two parameters, a node and
Expand Down Expand Up @@ -952,7 +952,8 @@ def _infer_str_format_call(

try:
formatted_string = format_template.format(*pos_values, **keyword_values)
except (IndexError, KeyError, TypeError, ValueError):
except (AttributeError, IndexError, KeyError, TypeError, ValueError):
# AttributeError: processing a replacement field using the arguments failed
# IndexError: there are too few arguments to interpolate
# TypeError: Unsupported format string
# ValueError: Unknown format code
Expand Down
2 changes: 1 addition & 1 deletion astroid/brain/brain_numpy_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def _get_numpy_version() -> tuple[str, str, str]:
import numpy # pylint: disable=import-outside-toplevel

return tuple(numpy.version.version.split("."))
except ImportError:
except (ImportError, AttributeError):
return ("0", "0", "0")


Expand Down
2 changes: 1 addition & 1 deletion astroid/brain/brain_uuid.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from astroid.nodes.scoped_nodes import ClassDef


def _patch_uuid_class(node):
def _patch_uuid_class(node: ClassDef) -> None:
# The .int member is patched using __dict__
node.locals["int"] = [Const(0, parent=node)]

Expand Down
11 changes: 9 additions & 2 deletions astroid/brain/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,18 @@
# For details: https://github.com/PyCQA/astroid/blob/main/LICENSE
# Copyright (c) https://github.com/PyCQA/astroid/blob/main/CONTRIBUTORS.txt

from __future__ import annotations

from collections.abc import Callable

from astroid.manager import AstroidManager
from astroid.nodes.scoped_nodes import Module


def register_module_extender(manager, module_name, get_extension_mod):
def transform(node):
def register_module_extender(
manager: AstroidManager, module_name: str, get_extension_mod: Callable[[], Module]
) -> None:
def transform(node: Module) -> None:
extension_module = get_extension_mod()
for name, objs in extension_module.locals.items():
node.locals[name] = objs
Expand Down
6 changes: 4 additions & 2 deletions astroid/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import inspect
import sys
import warnings
from collections.abc import Callable
from collections.abc import Callable, Generator
from typing import TypeVar

import wrapt
Expand Down Expand Up @@ -97,7 +97,9 @@ def path_wrapper(func):
"""

@functools.wraps(func)
def wrapped(node, context: InferenceContext | None = None, _func=func, **kwargs):
def wrapped(
node, context: InferenceContext | None = None, _func=func, **kwargs
) -> Generator:
"""wrapper function handling context"""
if context is None:
context = InferenceContext()
Expand Down

0 comments on commit 8a2eb84

Please sign in to comment.