Skip to content

Add Hint for Type Narrowing When Using Optional Types #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 27 commits into from
Sep 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
72c413d
stubgen: Use `Generator` type var defaults (#17670)
srittau Sep 12, 2024
f8195bc
Sync typeshed (#17772)
github-actions[bot] Sep 15, 2024
8b1e606
Make changelog visible in mypy documentation (#17742)
quinn-sasha Sep 15, 2024
77919cf
Add missing lines-covered and lines-valid attributes (#17738)
x612skm Sep 15, 2024
5c38427
Check for `truthy-bool` in `not ...` unary expressions (#17773)
sobolevn Sep 15, 2024
f68f76d
[PEP 695] Fix nested generic classes (#17776)
JukkaL Sep 18, 2024
a47f301
[PEP 695] Support Annotated[...] in new-style type aliases (#17777)
JukkaL Sep 18, 2024
fce14a0
[PEP 695] Allow covariance with attribute that has "_" name prefix (#…
JukkaL Sep 18, 2024
9d7a042
[PEP 695] Fix covariance of frozen dataclasses (#17783)
JukkaL Sep 18, 2024
4554bd0
Added error code for overlapping function signatures (#17597)
katconnors Sep 18, 2024
2a8c91e
[PEP 695] Fix crash on invalid type var reference (#17788)
JukkaL Sep 19, 2024
a646f33
[PEP 695] Inherit variance if base class has explicit variance (#17787)
JukkaL Sep 19, 2024
18fee78
[PEP 695] Generate error if new-style type alias used as base class (…
JukkaL Sep 20, 2024
5dfc7d9
[PEP 695] Enable new type parameter syntax by default (#17798)
JukkaL Sep 20, 2024
94109aa
Fix TypeVar upper bounds sometimes not being displayed in pretty call…
brianschubert Sep 21, 2024
9ffb9dd
Fix crash when passing too many type arguments to generic base class …
brianschubert Sep 21, 2024
cf3db99
Copyedit final_attrs.rst (#17813)
michen00 Sep 24, 2024
9518b6a
Reject ParamSpec-typed callables calls with insufficient arguments (#…
sterliakov Sep 24, 2024
ecfab6a
[PEP 695] Allow Self return types with contravariance (#17786)
JukkaL Sep 24, 2024
5c5e051
Test against latest Python 3.13, make testing 3.14 easy (#17812)
hauntsaninja Sep 25, 2024
58825f7
[PEP 695] Document Python 3.12 type parameter syntax (#17816)
JukkaL Sep 25, 2024
7f3d7f8
[PEP 695] Further documentation updates (#17826)
JukkaL Sep 25, 2024
f6520c8
Narrow falsey str/bytes/int to literal type (#17818)
brianschubert Sep 26, 2024
6336ce1
Discuss upper bounds before self types in documentation (#17827)
JukkaL Sep 26, 2024
0dfb718
Update various references to deprecated type aliases in docs (#17829)
JukkaL Sep 26, 2024
db7b61b
Make "X | Y" union syntax more prominent in documentation (#17835)
JukkaL Sep 26, 2024
7237d55
Sync typeshed (#17833)
cdce8p Sep 26, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 58 additions & 24 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,22 @@ jobs:
tox_extra_args: "-n 4"
test_mypyc: true

- name: Test suit with py313-dev-ubuntu, mypyc-compiled
python: '3.13-dev'
arch: x64
os: ubuntu-latest
toxenv: py
tox_extra_args: "-n 4"
test_mypyc: true
# - name: Test suit with py314-dev-ubuntu
# python: '3.14-dev'
# arch: x64
# os: ubuntu-latest
# toxenv: py
# tox_extra_args: "-n 4"
# allow_failure: true
# test_mypyc: true

- name: mypyc runtime tests with py39-macos
python: '3.9.18'
arch: x64
Expand Down Expand Up @@ -119,51 +135,69 @@ jobs:
MYPY_FORCE_TERMINAL_WIDTH: 200
# Pytest
PYTEST_ADDOPTS: --color=yes

steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python }}
architecture: ${{ matrix.arch }}

- name: Debug build
if: ${{ matrix.debug_build }}
run: |
PYTHONVERSION=${{ matrix.python }}
PYTHONDIR=~/python-debug/python-$PYTHONVERSION
VENV=$PYTHONDIR/env
./misc/build-debug-python.sh $PYTHONVERSION $PYTHONDIR $VENV
# TODO: does this do anything? env vars aren't passed to the next step right
source $VENV/bin/activate
- name: Latest Dev build
if: ${{ endsWith(matrix.python, '-dev') }}
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends \
build-essential gdb lcov libbz2-dev libffi-dev libgdbm-dev liblzma-dev libncurses5-dev \
libreadline6-dev libsqlite3-dev libssl-dev lzma lzma-dev tk-dev uuid-dev zlib1g-dev
git clone --depth 1 https://github.com/python/cpython.git /tmp/cpython --branch $( echo ${{ matrix.python }} | sed 's/-dev//' )
cd /tmp/cpython
echo git rev-parse HEAD; git rev-parse HEAD
git show --no-patch
./configure --prefix=/opt/pythondev
make -j$(nproc)
sudo make install
sudo ln -s /opt/pythondev/bin/python3 /opt/pythondev/bin/python
sudo ln -s /opt/pythondev/bin/pip3 /opt/pythondev/bin/pip
echo "/opt/pythondev/bin" >> $GITHUB_PATH
- uses: actions/setup-python@v5
if: ${{ !(matrix.debug_build || endsWith(matrix.python, '-dev')) }}
with:
python-version: ${{ matrix.python }}
architecture: ${{ matrix.arch }}

- name: Install tox
run: pip install setuptools==68.2.2 tox==4.11.0
run: |
echo PATH; echo $PATH
echo which python; which python
echo which pip; which pip
echo python version; python -c 'import sys; print(sys.version)'
echo debug build; python -c 'import sysconfig; print(bool(sysconfig.get_config_var("Py_DEBUG")))'
echo os.cpu_count; python -c 'import os; print(os.cpu_count())'
echo os.sched_getaffinity; python -c 'import os; print(len(getattr(os, "sched_getaffinity", lambda *args: [])(0)))'
pip install setuptools==68.2.2 tox==4.11.0

- name: Compiled with mypyc
if: ${{ matrix.test_mypyc }}
run: |
pip install -r test-requirements.txt
CC=clang MYPYC_OPT_LEVEL=0 MYPY_USE_MYPYC=1 pip install -e .

- name: Setup tox environment
run: |
tox run -e ${{ matrix.toxenv }} --notest
python -c 'import os; print("os.cpu_count", os.cpu_count(), "os.sched_getaffinity", len(getattr(os, "sched_getaffinity", lambda *args: [])(0)))'
tox run -e ${{ matrix.toxenv }} --notes
- name: Test
run: tox run -e ${{ matrix.toxenv }} --skip-pkg-install -- ${{ matrix.tox_extra_args }}
continue-on-error: ${{ matrix.allow_failure == 'true' }}

python-nightly:
runs-on: ubuntu-latest
name: Test suite with Python nightly
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: '3.13-dev'
- name: Install tox
run: pip install setuptools==68.2.2 tox==4.11.0
- name: Setup tox environment
run: tox run -e py --notest
- name: Test
run: tox run -e py --skip-pkg-install -- "-n 4"
continue-on-error: true
- name: Mark as a success
run: exit 0
- name: Mark as success (check failures manually)
if: ${{ matrix.allow_failure == 'true' }}
run: exit 0

python_32bits:
runs-on: ubuntu-latest
Expand Down
Loading