File tree 3 files changed +243
-1
lines changed 3 files changed +243
-1
lines changed Original file line number Diff line number Diff line change @@ -604,6 +604,8 @@ match match:
604
604
case 1: pass
605
605
case 2:
606
606
pass
607
+ match = lambda query: query == event
608
+ print(match(12))
607
609
"# ,
608
610
"<test>" ,
609
611
)
Original file line number Diff line number Diff line change @@ -1671,4 +1671,240 @@ expression: parse_ast
1671
1671
],
1672
1672
},
1673
1673
},
1674
+ Located {
1675
+ location: Location {
1676
+ row: 21 ,
1677
+ column: 0 ,
1678
+ },
1679
+ end_location: Some (
1680
+ Location {
1681
+ row: 21 ,
1682
+ column: 36 ,
1683
+ },
1684
+ ),
1685
+ custom: (),
1686
+ node: Assign {
1687
+ targets: [
1688
+ Located {
1689
+ location: Location {
1690
+ row: 21 ,
1691
+ column: 0 ,
1692
+ },
1693
+ end_location: Some (
1694
+ Location {
1695
+ row: 21 ,
1696
+ column: 5 ,
1697
+ },
1698
+ ),
1699
+ custom: (),
1700
+ node: Name {
1701
+ id: " match" ,
1702
+ ctx: Store ,
1703
+ },
1704
+ },
1705
+ ],
1706
+ value: Located {
1707
+ location: Location {
1708
+ row: 21 ,
1709
+ column: 8 ,
1710
+ },
1711
+ end_location: Some (
1712
+ Location {
1713
+ row: 21 ,
1714
+ column: 36 ,
1715
+ },
1716
+ ),
1717
+ custom: (),
1718
+ node: Lambda {
1719
+ args: Arguments {
1720
+ posonlyargs: [],
1721
+ args: [
1722
+ Located {
1723
+ location: Location {
1724
+ row: 21 ,
1725
+ column: 15 ,
1726
+ },
1727
+ end_location: Some (
1728
+ Location {
1729
+ row: 21 ,
1730
+ column: 20 ,
1731
+ },
1732
+ ),
1733
+ custom: (),
1734
+ node: ArgData {
1735
+ arg: " query" ,
1736
+ annotation: None ,
1737
+ type_comment: None ,
1738
+ },
1739
+ },
1740
+ ],
1741
+ vararg: None ,
1742
+ kwonlyargs: [],
1743
+ kw_defaults: [],
1744
+ kwarg: None ,
1745
+ defaults: [],
1746
+ },
1747
+ body: Located {
1748
+ location: Location {
1749
+ row: 21 ,
1750
+ column: 22 ,
1751
+ },
1752
+ end_location: Some (
1753
+ Location {
1754
+ row: 21 ,
1755
+ column: 36 ,
1756
+ },
1757
+ ),
1758
+ custom: (),
1759
+ node: Compare {
1760
+ left: Located {
1761
+ location: Location {
1762
+ row: 21 ,
1763
+ column: 22 ,
1764
+ },
1765
+ end_location: Some (
1766
+ Location {
1767
+ row: 21 ,
1768
+ column: 27 ,
1769
+ },
1770
+ ),
1771
+ custom: (),
1772
+ node: Name {
1773
+ id: " query" ,
1774
+ ctx: Load ,
1775
+ },
1776
+ },
1777
+ ops: [
1778
+ Eq ,
1779
+ ],
1780
+ comparators: [
1781
+ Located {
1782
+ location: Location {
1783
+ row: 21 ,
1784
+ column: 31 ,
1785
+ },
1786
+ end_location: Some (
1787
+ Location {
1788
+ row: 21 ,
1789
+ column: 36 ,
1790
+ },
1791
+ ),
1792
+ custom: (),
1793
+ node: Name {
1794
+ id: " event" ,
1795
+ ctx: Load ,
1796
+ },
1797
+ },
1798
+ ],
1799
+ },
1800
+ },
1801
+ },
1802
+ },
1803
+ type_comment: None ,
1804
+ },
1805
+ },
1806
+ Located {
1807
+ location: Location {
1808
+ row: 22 ,
1809
+ column: 0 ,
1810
+ },
1811
+ end_location: Some (
1812
+ Location {
1813
+ row: 22 ,
1814
+ column: 16 ,
1815
+ },
1816
+ ),
1817
+ custom: (),
1818
+ node: Expr {
1819
+ value: Located {
1820
+ location: Location {
1821
+ row: 22 ,
1822
+ column: 0 ,
1823
+ },
1824
+ end_location: Some (
1825
+ Location {
1826
+ row: 22 ,
1827
+ column: 16 ,
1828
+ },
1829
+ ),
1830
+ custom: (),
1831
+ node: Call {
1832
+ func: Located {
1833
+ location: Location {
1834
+ row: 22 ,
1835
+ column: 0 ,
1836
+ },
1837
+ end_location: Some (
1838
+ Location {
1839
+ row: 22 ,
1840
+ column: 5 ,
1841
+ },
1842
+ ),
1843
+ custom: (),
1844
+ node: Name {
1845
+ id: " print" ,
1846
+ ctx: Load ,
1847
+ },
1848
+ },
1849
+ args: [
1850
+ Located {
1851
+ location: Location {
1852
+ row: 22 ,
1853
+ column: 6 ,
1854
+ },
1855
+ end_location: Some (
1856
+ Location {
1857
+ row: 22 ,
1858
+ column: 15 ,
1859
+ },
1860
+ ),
1861
+ custom: (),
1862
+ node: Call {
1863
+ func: Located {
1864
+ location: Location {
1865
+ row: 22 ,
1866
+ column: 6 ,
1867
+ },
1868
+ end_location: Some (
1869
+ Location {
1870
+ row: 22 ,
1871
+ column: 11 ,
1872
+ },
1873
+ ),
1874
+ custom: (),
1875
+ node: Name {
1876
+ id: " match" ,
1877
+ ctx: Load ,
1878
+ },
1879
+ },
1880
+ args: [
1881
+ Located {
1882
+ location: Location {
1883
+ row: 22 ,
1884
+ column: 12 ,
1885
+ },
1886
+ end_location: Some (
1887
+ Location {
1888
+ row: 22 ,
1889
+ column: 14 ,
1890
+ },
1891
+ ),
1892
+ custom: (),
1893
+ node: Constant {
1894
+ value: Int (
1895
+ 12 ,
1896
+ ),
1897
+ kind: None ,
1898
+ },
1899
+ },
1900
+ ],
1901
+ keywords: [],
1902
+ },
1903
+ },
1904
+ ],
1905
+ keywords: [],
1906
+ },
1907
+ },
1908
+ },
1909
+ },
1674
1910
]
Original file line number Diff line number Diff line change @@ -59,11 +59,15 @@ where
59
59
let mut nesting = 0 ;
60
60
let mut first = true ;
61
61
let mut seen_colon = false ;
62
+ let mut seen_lambda = false ;
62
63
while let Some ( Ok ( ( _, tok, _) ) ) = self . underlying . peek ( ) {
63
64
match tok {
64
65
Tok :: Newline => break ,
66
+ Tok :: Lambda if nesting == 0 => seen_lambda = true ,
65
67
Tok :: Colon if nesting == 0 => {
66
- if !first {
68
+ if seen_lambda {
69
+ seen_lambda = false ;
70
+ } else if !first {
67
71
seen_colon = true ;
68
72
}
69
73
}
You can’t perform that action at this time.
0 commit comments