|
4 | 4 | from __future__ import annotations
|
5 | 5 |
|
6 | 6 | import operator
|
7 |
| -from typing import TYPE_CHECKING, Any, Callable, NoReturn, overload |
| 7 | +from typing import TYPE_CHECKING, Any, Callable, overload |
8 | 8 |
|
9 | 9 | from xarray.core import nputils, ops
|
10 | 10 | from xarray.core.types import (
|
@@ -446,201 +446,201 @@ def _binary_op(
|
446 | 446 | raise NotImplementedError
|
447 | 447 |
|
448 | 448 | @overload
|
449 |
| - def __add__(self, other: T_DataArray) -> NoReturn: |
| 449 | + def __add__(self, other: T_DataArray) -> T_DataArray: |
450 | 450 | ...
|
451 | 451 |
|
452 | 452 | @overload
|
453 | 453 | def __add__(self, other: VarCompatible) -> Self:
|
454 | 454 | ...
|
455 | 455 |
|
456 |
| - def __add__(self, other: VarCompatible) -> Self: |
| 456 | + def __add__(self, other: VarCompatible) -> Self | T_DataArray: |
457 | 457 | return self._binary_op(other, operator.add)
|
458 | 458 |
|
459 | 459 | @overload
|
460 |
| - def __sub__(self, other: T_DataArray) -> NoReturn: |
| 460 | + def __sub__(self, other: T_DataArray) -> T_DataArray: |
461 | 461 | ...
|
462 | 462 |
|
463 | 463 | @overload
|
464 | 464 | def __sub__(self, other: VarCompatible) -> Self:
|
465 | 465 | ...
|
466 | 466 |
|
467 |
| - def __sub__(self, other: VarCompatible) -> Self: |
| 467 | + def __sub__(self, other: VarCompatible) -> Self | T_DataArray: |
468 | 468 | return self._binary_op(other, operator.sub)
|
469 | 469 |
|
470 | 470 | @overload
|
471 |
| - def __mul__(self, other: T_DataArray) -> NoReturn: |
| 471 | + def __mul__(self, other: T_DataArray) -> T_DataArray: |
472 | 472 | ...
|
473 | 473 |
|
474 | 474 | @overload
|
475 | 475 | def __mul__(self, other: VarCompatible) -> Self:
|
476 | 476 | ...
|
477 | 477 |
|
478 |
| - def __mul__(self, other: VarCompatible) -> Self: |
| 478 | + def __mul__(self, other: VarCompatible) -> Self | T_DataArray: |
479 | 479 | return self._binary_op(other, operator.mul)
|
480 | 480 |
|
481 | 481 | @overload
|
482 |
| - def __pow__(self, other: T_DataArray) -> NoReturn: |
| 482 | + def __pow__(self, other: T_DataArray) -> T_DataArray: |
483 | 483 | ...
|
484 | 484 |
|
485 | 485 | @overload
|
486 | 486 | def __pow__(self, other: VarCompatible) -> Self:
|
487 | 487 | ...
|
488 | 488 |
|
489 |
| - def __pow__(self, other: VarCompatible) -> Self: |
| 489 | + def __pow__(self, other: VarCompatible) -> Self | T_DataArray: |
490 | 490 | return self._binary_op(other, operator.pow)
|
491 | 491 |
|
492 | 492 | @overload
|
493 |
| - def __truediv__(self, other: T_DataArray) -> NoReturn: |
| 493 | + def __truediv__(self, other: T_DataArray) -> T_DataArray: |
494 | 494 | ...
|
495 | 495 |
|
496 | 496 | @overload
|
497 | 497 | def __truediv__(self, other: VarCompatible) -> Self:
|
498 | 498 | ...
|
499 | 499 |
|
500 |
| - def __truediv__(self, other: VarCompatible) -> Self: |
| 500 | + def __truediv__(self, other: VarCompatible) -> Self | T_DataArray: |
501 | 501 | return self._binary_op(other, operator.truediv)
|
502 | 502 |
|
503 | 503 | @overload
|
504 |
| - def __floordiv__(self, other: T_DataArray) -> NoReturn: |
| 504 | + def __floordiv__(self, other: T_DataArray) -> T_DataArray: |
505 | 505 | ...
|
506 | 506 |
|
507 | 507 | @overload
|
508 | 508 | def __floordiv__(self, other: VarCompatible) -> Self:
|
509 | 509 | ...
|
510 | 510 |
|
511 |
| - def __floordiv__(self, other: VarCompatible) -> Self: |
| 511 | + def __floordiv__(self, other: VarCompatible) -> Self | T_DataArray: |
512 | 512 | return self._binary_op(other, operator.floordiv)
|
513 | 513 |
|
514 | 514 | @overload
|
515 |
| - def __mod__(self, other: T_DataArray) -> NoReturn: |
| 515 | + def __mod__(self, other: T_DataArray) -> T_DataArray: |
516 | 516 | ...
|
517 | 517 |
|
518 | 518 | @overload
|
519 | 519 | def __mod__(self, other: VarCompatible) -> Self:
|
520 | 520 | ...
|
521 | 521 |
|
522 |
| - def __mod__(self, other: VarCompatible) -> Self: |
| 522 | + def __mod__(self, other: VarCompatible) -> Self | T_DataArray: |
523 | 523 | return self._binary_op(other, operator.mod)
|
524 | 524 |
|
525 | 525 | @overload
|
526 |
| - def __and__(self, other: T_DataArray) -> NoReturn: |
| 526 | + def __and__(self, other: T_DataArray) -> T_DataArray: |
527 | 527 | ...
|
528 | 528 |
|
529 | 529 | @overload
|
530 | 530 | def __and__(self, other: VarCompatible) -> Self:
|
531 | 531 | ...
|
532 | 532 |
|
533 |
| - def __and__(self, other: VarCompatible) -> Self: |
| 533 | + def __and__(self, other: VarCompatible) -> Self | T_DataArray: |
534 | 534 | return self._binary_op(other, operator.and_)
|
535 | 535 |
|
536 | 536 | @overload
|
537 |
| - def __xor__(self, other: T_DataArray) -> NoReturn: |
| 537 | + def __xor__(self, other: T_DataArray) -> T_DataArray: |
538 | 538 | ...
|
539 | 539 |
|
540 | 540 | @overload
|
541 | 541 | def __xor__(self, other: VarCompatible) -> Self:
|
542 | 542 | ...
|
543 | 543 |
|
544 |
| - def __xor__(self, other: VarCompatible) -> Self: |
| 544 | + def __xor__(self, other: VarCompatible) -> Self | T_DataArray: |
545 | 545 | return self._binary_op(other, operator.xor)
|
546 | 546 |
|
547 | 547 | @overload
|
548 |
| - def __or__(self, other: T_DataArray) -> NoReturn: |
| 548 | + def __or__(self, other: T_DataArray) -> T_DataArray: |
549 | 549 | ...
|
550 | 550 |
|
551 | 551 | @overload
|
552 | 552 | def __or__(self, other: VarCompatible) -> Self:
|
553 | 553 | ...
|
554 | 554 |
|
555 |
| - def __or__(self, other: VarCompatible) -> Self: |
| 555 | + def __or__(self, other: VarCompatible) -> Self | T_DataArray: |
556 | 556 | return self._binary_op(other, operator.or_)
|
557 | 557 |
|
558 | 558 | @overload
|
559 |
| - def __lshift__(self, other: T_DataArray) -> NoReturn: |
| 559 | + def __lshift__(self, other: T_DataArray) -> T_DataArray: |
560 | 560 | ...
|
561 | 561 |
|
562 | 562 | @overload
|
563 | 563 | def __lshift__(self, other: VarCompatible) -> Self:
|
564 | 564 | ...
|
565 | 565 |
|
566 |
| - def __lshift__(self, other: VarCompatible) -> Self: |
| 566 | + def __lshift__(self, other: VarCompatible) -> Self | T_DataArray: |
567 | 567 | return self._binary_op(other, operator.lshift)
|
568 | 568 |
|
569 | 569 | @overload
|
570 |
| - def __rshift__(self, other: T_DataArray) -> NoReturn: |
| 570 | + def __rshift__(self, other: T_DataArray) -> T_DataArray: |
571 | 571 | ...
|
572 | 572 |
|
573 | 573 | @overload
|
574 | 574 | def __rshift__(self, other: VarCompatible) -> Self:
|
575 | 575 | ...
|
576 | 576 |
|
577 |
| - def __rshift__(self, other: VarCompatible) -> Self: |
| 577 | + def __rshift__(self, other: VarCompatible) -> Self | T_DataArray: |
578 | 578 | return self._binary_op(other, operator.rshift)
|
579 | 579 |
|
580 | 580 | @overload
|
581 |
| - def __lt__(self, other: T_DataArray) -> NoReturn: |
| 581 | + def __lt__(self, other: T_DataArray) -> T_DataArray: |
582 | 582 | ...
|
583 | 583 |
|
584 | 584 | @overload
|
585 | 585 | def __lt__(self, other: VarCompatible) -> Self:
|
586 | 586 | ...
|
587 | 587 |
|
588 |
| - def __lt__(self, other: VarCompatible) -> Self: |
| 588 | + def __lt__(self, other: VarCompatible) -> Self | T_DataArray: |
589 | 589 | return self._binary_op(other, operator.lt)
|
590 | 590 |
|
591 | 591 | @overload
|
592 |
| - def __le__(self, other: T_DataArray) -> NoReturn: |
| 592 | + def __le__(self, other: T_DataArray) -> T_DataArray: |
593 | 593 | ...
|
594 | 594 |
|
595 | 595 | @overload
|
596 | 596 | def __le__(self, other: VarCompatible) -> Self:
|
597 | 597 | ...
|
598 | 598 |
|
599 |
| - def __le__(self, other: VarCompatible) -> Self: |
| 599 | + def __le__(self, other: VarCompatible) -> Self | T_DataArray: |
600 | 600 | return self._binary_op(other, operator.le)
|
601 | 601 |
|
602 | 602 | @overload
|
603 |
| - def __gt__(self, other: T_DataArray) -> NoReturn: |
| 603 | + def __gt__(self, other: T_DataArray) -> T_DataArray: |
604 | 604 | ...
|
605 | 605 |
|
606 | 606 | @overload
|
607 | 607 | def __gt__(self, other: VarCompatible) -> Self:
|
608 | 608 | ...
|
609 | 609 |
|
610 |
| - def __gt__(self, other: VarCompatible) -> Self: |
| 610 | + def __gt__(self, other: VarCompatible) -> Self | T_DataArray: |
611 | 611 | return self._binary_op(other, operator.gt)
|
612 | 612 |
|
613 | 613 | @overload
|
614 |
| - def __ge__(self, other: T_DataArray) -> NoReturn: |
| 614 | + def __ge__(self, other: T_DataArray) -> T_DataArray: |
615 | 615 | ...
|
616 | 616 |
|
617 | 617 | @overload
|
618 | 618 | def __ge__(self, other: VarCompatible) -> Self:
|
619 | 619 | ...
|
620 | 620 |
|
621 |
| - def __ge__(self, other: VarCompatible) -> Self: |
| 621 | + def __ge__(self, other: VarCompatible) -> Self | T_DataArray: |
622 | 622 | return self._binary_op(other, operator.ge)
|
623 | 623 |
|
624 | 624 | @overload # type:ignore[override]
|
625 |
| - def __eq__(self, other: T_DataArray) -> NoReturn: |
| 625 | + def __eq__(self, other: T_DataArray) -> T_DataArray: |
626 | 626 | ...
|
627 | 627 |
|
628 | 628 | @overload
|
629 | 629 | def __eq__(self, other: VarCompatible) -> Self:
|
630 | 630 | ...
|
631 | 631 |
|
632 |
| - def __eq__(self, other: VarCompatible) -> Self: |
| 632 | + def __eq__(self, other: VarCompatible) -> Self | T_DataArray: |
633 | 633 | return self._binary_op(other, nputils.array_eq)
|
634 | 634 |
|
635 | 635 | @overload # type:ignore[override]
|
636 |
| - def __ne__(self, other: T_DataArray) -> NoReturn: |
| 636 | + def __ne__(self, other: T_DataArray) -> T_DataArray: |
637 | 637 | ...
|
638 | 638 |
|
639 | 639 | @overload
|
640 | 640 | def __ne__(self, other: VarCompatible) -> Self:
|
641 | 641 | ...
|
642 | 642 |
|
643 |
| - def __ne__(self, other: VarCompatible) -> Self: |
| 643 | + def __ne__(self, other: VarCompatible) -> Self | T_DataArray: |
644 | 644 | return self._binary_op(other, nputils.array_ne)
|
645 | 645 |
|
646 | 646 | def __radd__(self, other: VarCompatible) -> Self:
|
|
0 commit comments