Skip to content

Commit

Permalink
Merge branch 're-enable-mypy' into resolving-all-mypy-attr-defined-er…
Browse files Browse the repository at this point in the history
…rors
  • Loading branch information
Avasam committed Sep 18, 2024
2 parents f9f784f + 377cd71 commit 476cabc
Show file tree
Hide file tree
Showing 52 changed files with 2,063 additions and 5,139 deletions.
2 changes: 1 addition & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 74.0.0
current_version = 74.1.2
commit = True
tag = True

Expand Down
12 changes: 7 additions & 5 deletions .github/workflows/pyright.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:
- gh-readonly-queue/**
tags:
# required if branches-ignore is supplied (jaraco/skeleton#103)
- '**'
- "**"
pull_request:
workflow_dispatch:

Expand All @@ -24,15 +24,17 @@ env:
# pin pyright version so a new version doesn't suddenly cause the CI to fail,
# until types-setuptools is removed from typeshed.
# For help with static-typing issues, or pyright update, ping @Avasam
#
# An exact version from https://github.com/microsoft/pyright/releases or "latest"
PYRIGHT_VERSION: "1.1.377"

# Environment variable to support color support (jaraco/skeleton#66)
FORCE_COLOR: 1

# Suppress noisy pip warnings
PIP_DISABLE_PIP_VERSION_CHECK: 'true'
PIP_NO_PYTHON_VERSION_WARNING: 'true'
PIP_NO_WARN_SCRIPT_LOCATION: 'true'
PIP_DISABLE_PIP_VERSION_CHECK: "true"
PIP_NO_PYTHON_VERSION_WARNING: "true"
PIP_NO_WARN_SCRIPT_LOCATION: "true"

jobs:
pyright:
Expand Down Expand Up @@ -65,7 +67,7 @@ jobs:
else
echo '> pip install pyright==${{ env.PYRIGHT_VERSION }}'
fi
echo 'pyright --threads'
echo '> pyright --threads'
shell: bash
- name: Run pyright
uses: jakebailey/pyright-action@v2
Expand Down
36 changes: 36 additions & 0 deletions NEWS.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,39 @@
v74.1.2
=======

Bugfixes
--------

- Fixed TypeError in sdist filelist processing by adding support for pathlib Paths for the build_base. (#4615)
- Removed degraded and deprecated ``test_integration`` (easy_install) from the test suite. (#4632)


v74.1.1
=======

Bugfixes
--------

- Fixed TypeError in ``msvc.EnvironmentInfo.return_env`` when no runtime redistributables are installed. (#1902)


v74.1.0
=======

Features
--------

- Added support for defining ``ext-modules`` via ``pyproject.toml``
(**EXPERIMENTAL**, may change in future releases). (#4568)


Bugfixes
--------

- Merge with pypa/distutils@3dcdf8567, removing the duplicate vendored copy of packaging. (#4622)
- Restored ``setuptools.msvc.Environmentinfo`` as it is used externally. (#4625)


v74.0.0
=======

Expand Down
7 changes: 7 additions & 0 deletions conftest.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import platform
import sys

import pytest
Expand Down Expand Up @@ -67,3 +68,9 @@ def conditional_skip(request):
pytest.skip("running integration tests only")
if not running_integration_tests and is_integration_test:
pytest.skip("skipping integration tests")


@pytest.fixture
def windows_only():
if platform.system() != 'Windows':
pytest.skip("Windows only")
53 changes: 41 additions & 12 deletions docs/userguide/ext_modules.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,22 +27,41 @@ and all project metadata configuration in the ``pyproject.toml`` file:
version = "0.42"
To instruct setuptools to compile the ``foo.c`` file into the extension module
``mylib.foo``, we need to add a ``setup.py`` file similar to the following:
``mylib.foo``, we need to define an appropriate configuration in either
``pyproject.toml`` [#pyproject.toml]_ or ``setup.py`` file ,
similar to the following:

.. code-block:: python
.. tab:: pyproject.toml

from setuptools import Extension, setup
.. code-block:: toml
setup(
ext_modules=[
Extension(
name="mylib.foo", # as it would be imported
# may include packages/namespaces separated by `.`
sources=["foo.c"], # all sources are compiled into a single binary file
),
[tool.setuptools]
ext-modules = [
{name = "mylib.foo", sources = ["foo.c"]}
]
)
.. tab:: setup.py

.. code-block:: python
from setuptools import Extension, setup
setup(
ext_modules=[
Extension(
name="mylib.foo",
sources=["foo.c"],
),
]
)
The ``name`` value corresponds to how the extension module would be
imported and may include packages/namespaces separated by ``.``.
The ``sources`` value is a list of all source files that are compiled
into a single binary file.
Optionally any other parameter of :class:`setuptools.Extension` can be defined
in the configuration file (but in the case of ``pyproject.toml`` they must be
written using :wiki:`kebab-case` convention).

.. seealso::
You can find more information on the `Python docs about C/C++ extensions`_.
Expand Down Expand Up @@ -168,6 +187,16 @@ Extension API Reference
.. autoclass:: setuptools.Extension


----

.. rubric:: Notes

.. [#pyproject.toml]
Declarative configuration of extension modules via ``pyproject.toml`` was
introduced recently and is still considered experimental.
Therefore it might change in future versions of ``setuptools``.
.. _Python docs about C/C++ extensions: https://docs.python.org/3/extending/extending.html
.. _Cython: https://cython.readthedocs.io/en/stable/index.html
.. _directory options: https://gcc.gnu.org/onlinedocs/gcc/Directory-Options.html
Expand Down
3 changes: 3 additions & 0 deletions docs/userguide/pyproject_config.rst
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ file, and can be set via the ``tool.setuptools`` table:
Key Value Type (TOML) Notes
========================= =========================== =========================
``py-modules`` array See tip below.
``ext-modules`` array of **Experimental** - Each item corresponds to a
tables/inline-tables :class:`setuptools.Extension` object and may define
the associated parameters in :wiki:`kebab-case`.
``packages`` array or ``find`` directive See tip below.
``package-dir`` table/inline-table Used when explicitly/manually listing ``packages``.
------------------------- --------------------------- -------------------------
Expand Down
23 changes: 17 additions & 6 deletions mypy.ini
Original file line number Diff line number Diff line change
@@ -1,19 +1,30 @@
[mypy]
# DO NOT MERGE THIS, testing local typeshed
custom_typeshed_dir = ../typeshed/
# CI should test for all versions, local development gets hints for oldest supported
# But our testing setup doesn't allow passing CLI arguments, so local devs have to set this manually.
# python_version = 3.8
## upstream

# Is the project well-typed?
strict = False

# Early opt-in even when strict = False
warn_unused_ignores = True
warn_redundant_casts = True
# required to support namespace packages: https://github.com/python/mypy/issues/14057
enable_error_code = ignore-without-code

# Support namespace packages per https://github.com/python/mypy/issues/14057
explicit_package_bases = True

disable_error_code =
# Disable due to many false positives
overload-overlap,

## local

# DO NOT MERGE THIS, testing local typeshed
custom_typeshed_dir = ../typeshed/

# CI should test for all versions, local development gets hints for oldest supported
# But our testing setup doesn't allow passing CLI arguments, so local devs have to set this manually.
# python_version = 3.8

exclude = (?x)(
# Avoid scanning Python files in generated folders
^build/
Expand Down
2 changes: 1 addition & 1 deletion pkg_resources/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2779,7 +2779,7 @@ def load(
if require:
# We could pass `env` and `installer` directly,
# but keeping `*args` and `**kwargs` for backwards compatibility
self.require(*args, **kwargs) # type: ignore
self.require(*args, **kwargs) # type: ignore[arg-type]
return self.resolve()

def resolve(self) -> _ResolvedEntryPoint:
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ backend-path = ["."]

[project]
name = "setuptools"
version = "74.0.0"
version = "74.1.2"
authors = [
{ name = "Python Packaging Authority", email = "distutils-sig@python.org" },
]
Expand Down
16 changes: 8 additions & 8 deletions pyrightconfig.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
{
"$schema": "https://raw.githubusercontent.com/microsoft/pyright/main/packages/vscode-pyright/schemas/pyrightconfig.schema.json",
"exclude": [
// Avoid scanning Python files in generated folders
"build",
".tox",
".eggs",
"**/_vendor", // Vendored
"setuptools/_distutils", // Vendored
"setuptools/config/_validate_pyproject/**", // Auto-generated
"setuptools/config/_validate_pyproject/**",
// These are vendored
"**/_vendor",
"setuptools/_distutils",
],
// Our testing setup doesn't allow passing CLI arguments, so local devs have to set this manually.
// "pythonVersion": "3.8",
Expand All @@ -15,15 +17,13 @@
"typeCheckingMode": "basic",
// Too many issues caused by dynamic patching, still worth fixing when we can
"reportAttributeAccessIssue": "warning",
// Fails on Python 3.12 due to missing distutils and on cygwin CI tests
"reportAssignmentType": "warning",
// Fails on Python 3.12 due to missing distutils
"reportMissingImports": "warning",
"reportOptionalCall": "warning",
// FIXME: A handful of reportOperatorIssue spread throughout the codebase
"reportOperatorIssue": "warning",
// Deferred initialization (initialize_options/finalize_options) causes many "potentially None" issues
// TODO: Fix with type-guards or by changing how it's initialized
"reportArgumentType": "warning", // A lot of these are caused by jaraco.path.build's spec argument not being a Mapping https://github.com/jaraco/jaraco.path/pull/3
// TODO: Fix with type-guards, by changing how it's initialized, or by casting initial assignments
"reportArgumentType": "warning",
"reportCallIssue": "warning",
"reportGeneralTypeIssues": "warning",
"reportOptionalIterable": "warning",
Expand Down
5 changes: 2 additions & 3 deletions setuptools/_distutils/_msvccompiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
Contains MSVCCompiler, an implementation of the abstract CCompiler class
for Microsoft Visual Studio 2015.
The module is compatible with VS 2015 and later. You can find legacy support
for older versions in distutils.msvc9compiler and distutils.msvccompiler.
This module requires VS 2015 or later.
"""

# Written by Perry Stoll
Expand Down Expand Up @@ -160,7 +159,7 @@ def _get_vc_env(plat_spec):
stderr=subprocess.STDOUT,
).decode('utf-16le', errors='replace')
except subprocess.CalledProcessError as exc:
log.error(exc.output)
log.error(exc.output) # noqa: RUF100, TRY400
raise DistutilsPlatformError(f"Error executing {exc.cmd}")

env = {
Expand Down
Empty file.

This file was deleted.

This file was deleted.

Loading

0 comments on commit 476cabc

Please sign in to comment.