Sync from SUSE:SLFO:Main python-mypy revision 1c35c1912a4c0e392d52706be6a579b5
This commit is contained in:
BIN
mypy-1.14.1.tar.gz
(Stored with Git LFS)
BIN
mypy-1.14.1.tar.gz
(Stored with Git LFS)
Binary file not shown.
BIN
mypy-1.16.0.tar.gz
(Stored with Git LFS)
Normal file
BIN
mypy-1.16.0.tar.gz
(Stored with Git LFS)
Normal file
Binary file not shown.
@@ -1,3 +1,264 @@
|
||||
-------------------------------------------------------------------
|
||||
Thu May 29 15:25:57 UTC 2025 - Matej Cepl <mcepl@cepl.eu>
|
||||
|
||||
- Remove upstreamed mypy-1.14.1-gcc15.patch
|
||||
- Update to 1.16.0:
|
||||
Different Property Getter and Setter Types
|
||||
|
||||
Mypy now supports using different types for a property getter and setter:
|
||||
|
||||
class A:
|
||||
_value: int
|
||||
|
||||
@property
|
||||
def foo(self) -> int:
|
||||
return self._value
|
||||
|
||||
@foo.setter
|
||||
def foo(self, x: str | int) -> None:
|
||||
try:
|
||||
self._value = int(x)
|
||||
except ValueError:
|
||||
raise Exception(f"'{x}' is not a valid value for 'foo'")
|
||||
|
||||
This was contributed by Ivan Levkivskyi (PR 18510).
|
||||
Flexible Variable Redefinitions (Experimental)
|
||||
|
||||
Mypy now allows unannotated variables to be freely redefined
|
||||
with different types when using the experimental
|
||||
--allow-redefinition-new flag. You will also need to enable
|
||||
--local-partial-types. Mypy will now infer a union type when
|
||||
different types are assigned to a variable:
|
||||
|
||||
# mypy: allow-redefinition-new, local-partial-types
|
||||
|
||||
def f(n: int, b: bool) -> int | str:
|
||||
if b:
|
||||
x = n
|
||||
else:
|
||||
x = str(n)
|
||||
# Type of 'x' is int | str here.
|
||||
return x
|
||||
|
||||
Without the new flag, mypy only supports inferring optional
|
||||
types (X | None) from multiple assignments, but now mypy can
|
||||
infer arbitrary union types.
|
||||
|
||||
An unannotated variable can now also have different types in
|
||||
different code locations:
|
||||
|
||||
# mypy: allow-redefinition-new, local-partial-types
|
||||
...
|
||||
|
||||
if cond():
|
||||
for x in range(n):
|
||||
# Type of 'x' is 'int' here
|
||||
...
|
||||
else:
|
||||
for x in ['a', 'b']:
|
||||
# Type of 'x' is 'str' here
|
||||
...
|
||||
|
||||
We are planning to turn this flag on by default in mypy 2.0,
|
||||
along with --local-partial-types. The feature is still
|
||||
experimental and has known issues, and the semantics may
|
||||
still change in the future. You may need to update or add
|
||||
type annotations when switching to the new behavior, but if
|
||||
you encounter anything unexpected, please create a GitHub
|
||||
issue.
|
||||
|
||||
This was contributed by Jukka Lehtosalo (PR 18727, PR 19153).
|
||||
Stricter Type Checking with Imprecise Types
|
||||
|
||||
Mypy can now detect additional errors in code that uses Any
|
||||
types or has missing function annotations.
|
||||
|
||||
When calling dict.get(x, None) on an object of type dict[str,
|
||||
Any], this now results in an optional type (in the past it
|
||||
was Any):
|
||||
|
||||
def f(d: dict[str, Any]) -> int:
|
||||
# Error: Return value has type "Any | None" but expected "int"
|
||||
return d.get("x", None)
|
||||
|
||||
Type narrowing using assignments can result in more precise
|
||||
types in the presence of Any types:
|
||||
|
||||
def foo(): ...
|
||||
|
||||
def bar(n: int) -> None:
|
||||
x = foo()
|
||||
# Type of 'x' is 'Any' here
|
||||
if n > 5:
|
||||
x = str(n)
|
||||
# Type of 'x' is 'str' here
|
||||
|
||||
When using --check-untyped-defs, unannotated overrides are
|
||||
now checked more strictly against superclass definitions.
|
||||
|
||||
Related PRs:
|
||||
|
||||
Use union types instead of join in binder (Ivan Levkivskyi, PR 18538)
|
||||
Check superclass compatibility of untyped methods if
|
||||
--check-untyped-defs is set (Stanislav Terliakov, PR
|
||||
18970)
|
||||
|
||||
Improvements to Attribute Resolution
|
||||
|
||||
This release includes several fixes to inconsistent
|
||||
resolution of attribute, method and descriptor types.
|
||||
|
||||
Consolidate descriptor handling (Ivan Levkivskyi, PR 18831)
|
||||
Make multiple inheritance checking use common semantics (Ivan Levkivskyi, PR 18876)
|
||||
Make method override checking use common semantics (Ivan Levkivskyi, PR 18870)
|
||||
Fix descriptor overload selection (Ivan Levkivskyi, PR 18868)
|
||||
Handle union types when binding self (Ivan Levkivskyi, PR 18867)
|
||||
Make variable override checking use common semantics (Ivan Levkivskyi, PR 18847)
|
||||
Make descriptor handling behave consistently (Ivan Levkivskyi, PR 18831)
|
||||
|
||||
Make Implementation for Abstract Overloads Optional
|
||||
|
||||
The implementation can now be omitted for abstract overloaded methods, even outside stubs:
|
||||
|
||||
from abc import abstractmethod
|
||||
from typing import overload
|
||||
|
||||
class C:
|
||||
@abstractmethod
|
||||
@overload
|
||||
def foo(self, x: int) -> int: ...
|
||||
|
||||
@abstractmethod
|
||||
@overload
|
||||
def foo(self, x: str) -> str: ...
|
||||
|
||||
# No implementation required for "foo"
|
||||
|
||||
This was contributed by Ivan Levkivskyi (PR 18882).
|
||||
Option to Exclude Everything in .gitignore
|
||||
|
||||
You can now use --exclude-gitignore to exclude everything in
|
||||
a .gitignore file from the mypy build. This behaves similar
|
||||
to excluding the paths using --exclude. We might enable this
|
||||
by default in a future mypy release.
|
||||
|
||||
This was contributed by Ivan Levkivskyi (PR 18696).
|
||||
Selectively Disable Deprecated Warnings
|
||||
|
||||
It's now possible to selectively disable warnings generated
|
||||
from warnings.deprecated using the --deprecated-calls-exclude
|
||||
option:
|
||||
|
||||
# mypy --enable-error-code deprecated
|
||||
# --deprecated-calls-exclude=foo.A
|
||||
import foo
|
||||
|
||||
foo.A().func() # OK, the deprecated warning is ignored
|
||||
|
||||
# file foo.py
|
||||
|
||||
from typing_extensions import deprecated
|
||||
|
||||
class A:
|
||||
@deprecated("Use A.func2 instead")
|
||||
def func(self): pass
|
||||
|
||||
...
|
||||
|
||||
Contributed by Marc Mueller (PR 18641)
|
||||
Annotating Native/Non-Native Classes in Mypyc
|
||||
|
||||
You can now declare a class as a non-native class when
|
||||
compiling with mypyc. Unlike native classes, which are
|
||||
extension classes and have an immutable structure, non-native
|
||||
classes are normal Python classes at runtime and are fully
|
||||
dynamic. Example:
|
||||
|
||||
from mypy_extensions import mypyc_attr
|
||||
|
||||
@mypyc_attr(native_class=False)
|
||||
class NonNativeClass:
|
||||
...
|
||||
|
||||
o = NonNativeClass()
|
||||
|
||||
# Ok, even if attribute "foo" not declared in class body
|
||||
setattr(o, "foo", 1)
|
||||
|
||||
Classes are native by default in compiled modules, but
|
||||
classes that use certain features (such as most metaclasses)
|
||||
are implicitly non-native.
|
||||
|
||||
You can also explicitly declare a class as native. In this
|
||||
case mypyc will generate an error if it can't compile the
|
||||
class as a native class, instead of falling back to
|
||||
a non-native class:
|
||||
|
||||
from mypy_extensions import mypyc_attr
|
||||
from foo import MyMeta
|
||||
|
||||
# Error: Unsupported metaclass for a native class
|
||||
@mypyc_attr(native_class=True)
|
||||
class C(metaclass=MyMeta):
|
||||
...
|
||||
|
||||
Since native classes are significantly more efficient that
|
||||
non-native classes, you may want to ensure that certain
|
||||
classes always compiled as native classes.
|
||||
|
||||
- Update to 1.15.0:
|
||||
|
||||
By default, mypy treats bytearray and memoryview values as
|
||||
assignable to the bytes type, for historical reasons. Use the
|
||||
--strict-bytes flag to disable this behavior. PEP 688
|
||||
specified the removal of this special case. The flag will be
|
||||
enabled by default in mypy 2.0.
|
||||
|
||||
Contributed by Ali Hamdan (PR 18263) and Shantanu Jain (PR 13952).
|
||||
Improvements to Reachability Analysis and Partial Type Handling in Loops
|
||||
|
||||
This change results in mypy better modelling control flow
|
||||
within loops and hence detecting several previously ignored
|
||||
issues. In some cases, this change may require additional
|
||||
explicit variable annotations.
|
||||
|
||||
Contributed by Christoph Tyralla (PR 18180, PR 18433).
|
||||
|
||||
(Speaking of partial types, remember that we plan to enable
|
||||
--local-partial-types by default in mypy 2.0.)
|
||||
Better Discovery of Configuration Files
|
||||
|
||||
Mypy will now walk up the filesystem (up until a repository
|
||||
or file system root) to discover configuration files. See the
|
||||
mypy configuration file documentation for more details.
|
||||
|
||||
Contributed by Mikhail Shiryaev and Shantanu Jain (PR 16965, PR 18482)
|
||||
Better Line Numbers for Decorators and Slice Expressions
|
||||
|
||||
Mypy now uses more correct line numbers for decorators and
|
||||
slice expressions. In some cases, you may have to change the
|
||||
location of a # type: ignore comment.
|
||||
|
||||
Contributed by Shantanu Jain (PR 18392, PR 18397).
|
||||
Drop Support for Python 3.8
|
||||
|
||||
Mypy no longer supports running with Python 3.8, which has
|
||||
reached end-of-life. When running mypy with Python 3.9+, it
|
||||
is still possible to type check code that needs to support
|
||||
Python 3.8 with the --python-version 3.8 argument. Support
|
||||
for this will be dropped in the first half of 2025!
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Mon May 5 13:29:04 UTC 2025 - Friedrich Haubensak <hsk17@mail.de>
|
||||
|
||||
- Add mypy-1.14.1-gcc15.patch from upstream to fix gcc15 compile
|
||||
time error
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Mon May 5 12:58:47 UTC 2025 - Matej Cepl <mcepl@cepl.eu>
|
||||
|
||||
- Update vendored types_* to the appropriate versions.
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Fri Jan 24 15:13:25 UTC 2025 - ecsos <ecsos@opensuse.org>
|
||||
|
||||
|
@@ -16,12 +16,12 @@
|
||||
#
|
||||
|
||||
|
||||
%{?sle15_python_module_pythons}
|
||||
%define types_psutil_version 7.0.0.20250401
|
||||
%define types_setuptools_version 78.1.0.20250329
|
||||
%bcond_without test
|
||||
%define types_psutil_version 6.0.0.20241011
|
||||
%define types_setuptools_version 75.1.0.20241014
|
||||
%{?sle15_python_module_pythons}
|
||||
Name: python-mypy
|
||||
Version: 1.14.1
|
||||
Version: 1.16.0
|
||||
Release: 0
|
||||
Summary: Optional static typing for Python
|
||||
License: MIT
|
||||
@@ -29,31 +29,32 @@ URL: https://www.mypy-lang.org/
|
||||
Source0: https://files.pythonhosted.org/packages/source/m/mypy/mypy-%{version}.tar.gz
|
||||
# Source0: mypy-%%{version}.tar.gz
|
||||
# License Source1: Apache-2.0. Only for the test suite, not packaged here.
|
||||
Source1: https://files.pythonhosted.org/packages/source/t/types-psutil/types-psutil-%{types_psutil_version}.tar.gz
|
||||
Source1: https://files.pythonhosted.org/packages/source/t/types_psutil/types_psutil-%{types_psutil_version}.tar.gz
|
||||
# License Source2: Apache-2.0. Only for the test suite, not packaged here.
|
||||
Source2: https://files.pythonhosted.org/packages/source/t/types-setuptools/types-setuptools-%{types_setuptools_version}.tar.gz
|
||||
Source2: https://files.pythonhosted.org/packages/source/t/types_setuptools/types_setuptools-%{types_setuptools_version}.tar.gz
|
||||
Source99: python-mypy-rpmlintrc
|
||||
BuildRequires: %{python_module exceptiongroup}
|
||||
BuildRequires: %{python_module mypy_extensions >= 1.0.0}
|
||||
BuildRequires: %{python_module pathspec}
|
||||
BuildRequires: %{python_module pip}
|
||||
BuildRequires: %{python_module setuptools}
|
||||
BuildRequires: %{python_module tomli >= 1.1.0}
|
||||
BuildRequires: %{python_module typing_extensions >= 4.6.0}
|
||||
BuildRequires: %{python_module wheel}
|
||||
BuildRequires: %{python_module wheel}
|
||||
BuildRequires: fdupes
|
||||
BuildRequires: python-rpm-macros
|
||||
Requires: python-mypy_extensions >= 0.4.3
|
||||
Requires: python-pathspec
|
||||
Requires: python-typing_extensions >= 3.10
|
||||
Requires: (python-tomli >= 1.1.0 if python-base < 3.11)
|
||||
Requires(post): update-alternatives
|
||||
Requires(postun):update-alternatives
|
||||
Requires(postun): update-alternatives
|
||||
Suggests: python-psutil >= 4.0
|
||||
BuildArch: noarch
|
||||
%if "%{python_flavor}" == "python3" || "%{?python_provides}" == "python3"
|
||||
Provides: mypy = %{version}
|
||||
Obsoletes: mypy < %{version}
|
||||
%endif
|
||||
Suggests: python-psutil >= 4.0
|
||||
BuildArch: noarch
|
||||
%if %{with test}
|
||||
BuildRequires: %{python_module attrs >= 18}
|
||||
BuildRequires: %{python_module devel}
|
||||
@@ -85,15 +86,16 @@ Mypy's type system features type inference, gradual typing, generics
|
||||
and union types.
|
||||
|
||||
%prep
|
||||
%setup -q -a 1 -a 2 -n mypy-%{version}
|
||||
%setup -q -a1 -n mypy-%{version}
|
||||
%setup -q -T -D -a2 -n mypy-%{version}
|
||||
%autopatch -p1
|
||||
|
||||
sed -i '/env python3/d' ./mypy/stubgenc.py
|
||||
sed -i '/env python3/d' ./mypy/stubgen.py
|
||||
|
||||
mkdir mystubs
|
||||
mv types-setuptools-%{types_setuptools_version}/setuptools-stubs* mystubs/
|
||||
mv types-psutil-%{types_psutil_version}/psutil-stubs* mystubs/
|
||||
mv types_setuptools-%{types_setuptools_version}/setuptools-stubs* mystubs/
|
||||
mv types_psutil-%{types_psutil_version}/psutil-stubs* mystubs/
|
||||
|
||||
# "E: wrong-script-end-of-line-encoding" and "E: spurious-executable-perm", file is not needed anyways
|
||||
rm docs/make.bat
|
||||
@@ -153,7 +155,7 @@ donttest+=" or PEP561Suite"
|
||||
%license LICENSE
|
||||
%{python_sitelib}/mypy
|
||||
%{python_sitelib}/mypyc
|
||||
# %{python_sitelib}/mypy-%%{version}.dist-info
|
||||
# %%{python_sitelib}/mypy-%%{version}.dist-info
|
||||
%{python_sitelib}/mypy-*.dist-info
|
||||
%python_alternative %{_bindir}/dmypy
|
||||
%python_alternative %{_bindir}/mypy
|
||||
|
BIN
types-psutil-6.0.0.20241011.tar.gz
(Stored with Git LFS)
BIN
types-psutil-6.0.0.20241011.tar.gz
(Stored with Git LFS)
Binary file not shown.
BIN
types-setuptools-75.1.0.20241014.tar.gz
(Stored with Git LFS)
BIN
types-setuptools-75.1.0.20241014.tar.gz
(Stored with Git LFS)
Binary file not shown.
BIN
types_psutil-7.0.0.20250401.tar.gz
(Stored with Git LFS)
Normal file
BIN
types_psutil-7.0.0.20250401.tar.gz
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
types_setuptools-78.1.0.20250329.tar.gz
(Stored with Git LFS)
Normal file
BIN
types_setuptools-78.1.0.20250329.tar.gz
(Stored with Git LFS)
Normal file
Binary file not shown.
Reference in New Issue
Block a user