How to use version_info method in tox

Best Python code snippet using tox_python

versioned_branches_test.py

Source:versioned_branches_test.py Github

copy

Full Screen

1from __future__ import annotations2import pytest3from pyupgrade._data import Settings4from pyupgrade._main import _fix_plugins5@pytest.mark.parametrize(6 's',7 (8 # we timidly skip `if` without `else` as it could cause a SyntaxError9 'if six.PY2:\n'10 ' pass',11 # here's the case where it causes a SyntaxError12 'if True:\n'13 ' if six.PY2:\n'14 ' pass\n',15 # for now we don't attempt to rewrite `elif`16 'if six.PY2:\n'17 ' pass\n'18 'elif False:\n'19 ' pass\n',20 'if six.PY3:\n'21 ' pass\n'22 'elif False:\n'23 ' pass\n',24 # don't rewrite version compares with not 3.0 compares25 'if sys.version_info >= (3, 6):\n'26 ' 3.6\n'27 'else:\n'28 ' 3.5\n',29 # don't try and think about `sys.version`30 'from sys import version\n'31 'if sys.version[0] > "2":\n'32 ' 3\n'33 'else:\n'34 ' 2\n',35 pytest.param(36 'from .sys import version_info\n'37 'if version_info < (3,):\n'38 ' print("2")\n'39 'else:\n'40 ' print("3")\n',41 id='relative imports',42 ),43 ),44)45def test_fix_py2_block_noop(s):46 assert _fix_plugins(s, settings=Settings()) == s47@pytest.mark.parametrize(48 ('s', 'expected'),49 (50 pytest.param(51 'if six.PY2:\n'52 ' print("py2")\n'53 'else:\n'54 ' print("py3")\n',55 'print("py3")\n',56 id='six.PY2',57 ),58 pytest.param(59 'if six.PY2:\n'60 ' if True:\n'61 ' print("py2!")\n'62 ' else:\n'63 ' print("???")\n'64 'else:\n'65 ' print("py3")\n',66 'print("py3")\n',67 id='six.PY2, nested ifs',68 ),69 pytest.param(70 'if six.PY2: print("PY2!")\n'71 'else: print("PY3!")\n',72 'print("PY3!")\n',73 id='six.PY2, oneline',74 ),75 pytest.param(76 'if six.PY2: print("PY2!")\n'77 'else: print("PY3!")',78 'print("PY3!")',79 id='six.PY2, oneline, no newline at end of file',80 ),81 pytest.param(82 'if True:\n'83 ' if six.PY2:\n'84 ' print("PY2")\n'85 ' else:\n'86 ' print("PY3")\n',87 'if True:\n'88 ' print("PY3")\n',89 id='six.PY2, indented',90 ),91 pytest.param(92 'if six.PY2: print(1 if True else 3)\n'93 'else:\n'94 ' print("py3")\n',95 'print("py3")\n',96 id='six.PY2, `else` token inside oneline if\n',97 ),98 pytest.param(99 'if six.PY2:\n'100 ' def f():\n'101 ' print("py2")\n'102 'else:\n'103 ' def f():\n'104 ' print("py3")\n',105 'def f():\n'106 ' print("py3")\n',107 id='six.PY2, multiple indents in block',108 ),109 pytest.param(110 'if not six.PY2:\n'111 ' print("py3")\n'112 'else:\n'113 ' print("py2")\n'114 '\n'115 '\n'116 'x = 1\n',117 'print("py3")\n'118 '\n'119 '\n'120 'x = 1\n',121 id='not six.PY2, remove second block',122 ),123 pytest.param(124 'if not six.PY2:\n'125 ' print("py3")\n'126 'else:\n'127 ' print("py2")',128 'print("py3")\n',129 id='not six.PY2, no end of line',130 ),131 pytest.param(132 'if not six.PY2:\n'133 ' print("py3")\n'134 'else:\n'135 ' print("py2")\n'136 ' # ohai\n'137 '\n'138 'x = 1\n',139 'print("py3")\n'140 '\n'141 'x = 1\n',142 id='not six.PY2: else block ends in comment',143 ),144 pytest.param(145 'if not six.PY2: print("py3")\n'146 'else: print("py2")\n',147 'print("py3")\n',148 id='not six.PY2, else is single line',149 ),150 pytest.param(151 'if six.PY3:\n'152 ' print("py3")\n'153 'else:\n'154 ' print("py2")\n',155 'print("py3")\n',156 id='six.PY3',157 ),158 pytest.param(159 'if True:\n'160 ' if six.PY3:\n'161 ' print("py3")\n'162 ' else:\n'163 ' print("py2")\n',164 'if True:\n'165 ' print("py3")\n',166 id='indented six.PY3',167 ),168 pytest.param(169 'from six import PY3\n'170 'if not PY3:\n'171 ' print("py2")\n'172 'else:\n'173 ' print("py3")\n',174 'from six import PY3\n'175 'print("py3")\n',176 id='not PY3',177 ),178 pytest.param(179 'def f():\n'180 ' if six.PY2:\n'181 ' try:\n'182 ' yield\n'183 ' finally:\n'184 ' pass\n'185 ' else:\n'186 ' yield\n',187 'def f():\n'188 ' yield\n',189 id='six.PY2, finally',190 ),191 pytest.param(192 'class C:\n'193 ' def g():\n'194 ' pass\n'195 '\n'196 ' if six.PY2:\n'197 ' def f(py2):\n'198 ' pass\n'199 ' else:\n'200 ' def f(py3):\n'201 ' pass\n'202 '\n'203 ' def h():\n'204 ' pass\n',205 'class C:\n'206 ' def g():\n'207 ' pass\n'208 '\n'209 ' def f(py3):\n'210 ' pass\n'211 '\n'212 ' def h():\n'213 ' pass\n',214 id='six.PY2 in class\n',215 ),216 pytest.param(217 'if True:\n'218 ' if six.PY2:\n'219 ' 2\n'220 ' else:\n'221 ' 3\n'222 '\n'223 ' # comment\n',224 'if True:\n'225 ' 3\n'226 '\n'227 ' # comment\n',228 id='six.PY2, comment after',229 ),230 pytest.param(231 'if six.PY2:\n'232 ' def f():\n'233 ' print("py2")\n'234 ' def g():\n'235 ' print("py2")\n'236 'else:\n'237 ' def f():\n'238 ' print("py3")\n'239 ' def g():\n'240 ' print("py3")\n',241 'def f():\n'242 ' print("py3")\n'243 'def g():\n'244 ' print("py3")\n',245 id='six.PY2 multiple functions',246 ),247 pytest.param(248 'if True:\n'249 ' if six.PY3:\n'250 ' 3\n'251 ' else:\n'252 ' 2\n'253 '\n'254 ' # comment\n',255 'if True:\n'256 ' 3\n'257 '\n'258 ' # comment\n',259 id='six.PY3, comment after',260 ),261 pytest.param(262 'if sys.version_info == 2:\n'263 ' 2\n'264 'else:\n'265 ' 3\n',266 '3\n',267 id='sys.version_info == 2',268 ),269 pytest.param(270 'if sys.version_info < (3,):\n'271 ' 2\n'272 'else:\n'273 ' 3\n',274 '3\n',275 id='sys.version_info < (3,)',276 ),277 pytest.param(278 'if sys.version_info < (3, 0):\n'279 ' 2\n'280 'else:\n'281 ' 3\n',282 '3\n',283 id='sys.version_info < (3, 0)',284 ),285 pytest.param(286 'if sys.version_info == 3:\n'287 ' 3\n'288 'else:\n'289 ' 2\n',290 '3\n',291 id='sys.version_info == 3',292 ),293 pytest.param(294 'if sys.version_info > (3,):\n'295 ' 3\n'296 'else:\n'297 ' 2\n',298 '3\n',299 id='sys.version_info > (3,)',300 ),301 pytest.param(302 'if sys.version_info >= (3,):\n'303 ' 3\n'304 'else:\n'305 ' 2\n',306 '3\n',307 id='sys.version_info >= (3,)',308 ),309 pytest.param(310 'from sys import version_info\n'311 'if version_info > (3,):\n'312 ' 3\n'313 'else:\n'314 ' 2\n',315 'from sys import version_info\n'316 '3\n',317 id='from sys import version_info, > (3,)',318 ),319 pytest.param(320 'if True:\n'321 ' print(1)\n'322 'elif six.PY2:\n'323 ' print(2)\n'324 'else:\n'325 ' print(3)\n',326 'if True:\n'327 ' print(1)\n'328 'else:\n'329 ' print(3)\n',330 id='elif six.PY2 else',331 ),332 pytest.param(333 'if True:\n'334 ' print(1)\n'335 'elif six.PY3:\n'336 ' print(3)\n'337 'else:\n'338 ' print(2)\n',339 'if True:\n'340 ' print(1)\n'341 'else:\n'342 ' print(3)\n',343 id='elif six.PY3 else',344 ),345 pytest.param(346 'if True:\n'347 ' print(1)\n'348 'elif six.PY3:\n'349 ' print(3)\n',350 'if True:\n'351 ' print(1)\n'352 'else:\n'353 ' print(3)\n',354 id='elif six.PY3 no else',355 ),356 pytest.param(357 'def f():\n'358 ' if True:\n'359 ' print(1)\n'360 ' elif six.PY3:\n'361 ' print(3)\n',362 'def f():\n'363 ' if True:\n'364 ' print(1)\n'365 ' else:\n'366 ' print(3)\n',367 id='elif six.PY3 no else, indented',368 ),369 pytest.param(370 'if True:\n'371 ' if sys.version_info > (3,):\n'372 ' print(3)\n'373 ' # comment\n'374 ' print(2+3)\n',375 'if True:\n'376 ' print(3)\n'377 ' # comment\n'378 ' print(2+3)\n',379 id='comment after dedented block',380 ),381 ),382)383def test_fix_py2_blocks(s, expected):384 ret = _fix_plugins(s, settings=Settings())385 assert ret == expected386@pytest.mark.parametrize(387 ('s', 'expected'),388 (389 ('if six.PY3: print(3)\n', 'print(3)\n'),390 (391 'if six.PY3:\n'392 ' print(3)\n',393 'print(3)\n',394 ),395 ),396)397def test_fix_py3_only_code(s, expected):398 ret = _fix_plugins(s, settings=Settings())399 assert ret == expected400@pytest.mark.parametrize(401 ('s', 'expected'),402 (403 pytest.param(404 'import sys\n'405 'if sys.version_info > (3, 5):\n'406 ' 3+6\n'407 'else:\n'408 ' 3-5\n',409 'import sys\n'410 '3+6\n',411 id='sys.version_info > (3, 5)',412 ),413 pytest.param(414 'from sys import version_info\n'415 'if version_info > (3, 5):\n'416 ' 3+6\n'417 'else:\n'418 ' 3-5\n',419 'from sys import version_info\n'420 '3+6\n',421 id='from sys import version_info, > (3, 5)',422 ),423 pytest.param(424 'import sys\n'425 'if sys.version_info >= (3, 6):\n'426 ' 3+6\n'427 'else:\n'428 ' 3-5\n',429 'import sys\n'430 '3+6\n',431 id='sys.version_info >= (3, 6)',432 ),433 pytest.param(434 'from sys import version_info\n'435 'if version_info >= (3, 6):\n'436 ' 3+6\n'437 'else:\n'438 ' 3-5\n',439 'from sys import version_info\n'440 '3+6\n',441 id='from sys import version_info, >= (3, 6)',442 ),443 pytest.param(444 'import sys\n'445 'if sys.version_info < (3, 6):\n'446 ' 3-5\n'447 'else:\n'448 ' 3+6\n',449 'import sys\n'450 '3+6\n',451 id='sys.version_info < (3, 6)',452 ),453 pytest.param(454 'from sys import version_info\n'455 'if version_info < (3, 6):\n'456 ' 3-5\n'457 'else:\n'458 ' 3+6\n',459 'from sys import version_info\n'460 '3+6\n',461 id='from sys import version_info, < (3, 6)',462 ),463 pytest.param(464 'import sys\n'465 'if sys.version_info <= (3, 5):\n'466 ' 3-5\n'467 'else:\n'468 ' 3+6\n',469 'import sys\n'470 '3+6\n',471 id='sys.version_info <= (3, 5)',472 ),473 pytest.param(474 'from sys import version_info\n'475 'if version_info <= (3, 5):\n'476 ' 3-5\n'477 'else:\n'478 ' 3+6\n',479 'from sys import version_info\n'480 '3+6\n',481 id='from sys import version_info, <= (3, 5)',482 ),483 pytest.param(484 'import sys\n'485 'if sys.version_info >= (3, 6):\n'486 ' pass',487 'import sys\n'488 'pass',489 id='sys.version_info >= (3, 6), noelse',490 ),491 ),492)493def test_fix_py3x_only_code(s, expected):494 ret = _fix_plugins(s, settings=Settings(min_version=(3, 6)))495 assert ret == expected496@pytest.mark.parametrize(497 's',498 (499 # both branches are still relevant in the following cases500 'import sys\n'501 'if sys.version_info > (3, 7):\n'502 ' 3-6\n'503 'else:\n'504 ' 3+7\n',505 'import sys\n'506 'if sys.version_info < (3, 7):\n'507 ' 3-6\n'508 'else:\n'509 ' 3+7\n',510 'import sys\n'511 'if sys.version_info >= (3, 7):\n'512 ' 3+7\n'513 'else:\n'514 ' 3-6\n',515 'import sys\n'516 'if sys.version_info <= (3, 7):\n'517 ' 3-7\n'518 'else:\n'519 ' 3+8\n',520 'import sys\n'521 'if sys.version_info <= (3, 6):\n'522 ' 3-6\n'523 'else:\n'524 ' 3+7\n',525 'import sys\n'526 'if sys.version_info > (3, 6):\n'527 ' 3+7\n'528 'else:\n'529 ' 3-6\n',530 ),531)532def test_fix_py3x_only_noop(s):...

Full Screen

Full Screen

_ast.pyi

Source:_ast.pyi Github

copy

Full Screen

1import sys2from typing import Any, ClassVar3from typing_extensions import Literal, TypeAlias4PyCF_ONLY_AST: Literal[1024]5if sys.version_info >= (3, 8):6 PyCF_TYPE_COMMENTS: Literal[4096]7 PyCF_ALLOW_TOP_LEVEL_AWAIT: Literal[8192]8_Identifier: TypeAlias = str9class AST:10 if sys.version_info >= (3, 10):11 __match_args__ = ()12 _attributes: ClassVar[tuple[str, ...]]13 _fields: ClassVar[tuple[str, ...]]14 def __init__(self, *args: Any, **kwargs: Any) -> None: ...15 # TODO: Not all nodes have all of the following attributes16 lineno: int17 col_offset: int18 if sys.version_info >= (3, 8):19 end_lineno: int | None20 end_col_offset: int | None21 type_comment: str | None22class mod(AST): ...23if sys.version_info >= (3, 8):24 class type_ignore(AST): ...25 class TypeIgnore(type_ignore):26 if sys.version_info >= (3, 10):27 __match_args__ = ("lineno", "tag")28 tag: str29 class FunctionType(mod):30 if sys.version_info >= (3, 10):31 __match_args__ = ("argtypes", "returns")32 argtypes: list[expr]33 returns: expr34class Module(mod):35 if sys.version_info >= (3, 10):36 __match_args__ = ("body", "type_ignores")37 body: list[stmt]38 if sys.version_info >= (3, 8):39 type_ignores: list[TypeIgnore]40class Interactive(mod):41 if sys.version_info >= (3, 10):42 __match_args__ = ("body",)43 body: list[stmt]44class Expression(mod):45 if sys.version_info >= (3, 10):46 __match_args__ = ("body",)47 body: expr48class stmt(AST): ...49class FunctionDef(stmt):50 if sys.version_info >= (3, 10):51 __match_args__ = ("name", "args", "body", "decorator_list", "returns", "type_comment")52 name: _Identifier53 args: arguments54 body: list[stmt]55 decorator_list: list[expr]56 returns: expr | None57class AsyncFunctionDef(stmt):58 if sys.version_info >= (3, 10):59 __match_args__ = ("name", "args", "body", "decorator_list", "returns", "type_comment")60 name: _Identifier61 args: arguments62 body: list[stmt]63 decorator_list: list[expr]64 returns: expr | None65class ClassDef(stmt):66 if sys.version_info >= (3, 10):67 __match_args__ = ("name", "bases", "keywords", "body", "decorator_list")68 name: _Identifier69 bases: list[expr]70 keywords: list[keyword]71 body: list[stmt]72 decorator_list: list[expr]73class Return(stmt):74 if sys.version_info >= (3, 10):75 __match_args__ = ("value",)76 value: expr | None77class Delete(stmt):78 if sys.version_info >= (3, 10):79 __match_args__ = ("targets",)80 targets: list[expr]81class Assign(stmt):82 if sys.version_info >= (3, 10):83 __match_args__ = ("targets", "value", "type_comment")84 targets: list[expr]85 value: expr86class AugAssign(stmt):87 if sys.version_info >= (3, 10):88 __match_args__ = ("target", "op", "value")89 target: expr90 op: operator91 value: expr92class AnnAssign(stmt):93 if sys.version_info >= (3, 10):94 __match_args__ = ("target", "annotation", "value", "simple")95 target: expr96 annotation: expr97 value: expr | None98 simple: int99class For(stmt):100 if sys.version_info >= (3, 10):101 __match_args__ = ("target", "iter", "body", "orelse", "type_comment")102 target: expr103 iter: expr104 body: list[stmt]105 orelse: list[stmt]106class AsyncFor(stmt):107 if sys.version_info >= (3, 10):108 __match_args__ = ("target", "iter", "body", "orelse", "type_comment")109 target: expr110 iter: expr111 body: list[stmt]112 orelse: list[stmt]113class While(stmt):114 if sys.version_info >= (3, 10):115 __match_args__ = ("test", "body", "orelse")116 test: expr117 body: list[stmt]118 orelse: list[stmt]119class If(stmt):120 if sys.version_info >= (3, 10):121 __match_args__ = ("test", "body", "orelse")122 test: expr123 body: list[stmt]124 orelse: list[stmt]125class With(stmt):126 if sys.version_info >= (3, 10):127 __match_args__ = ("items", "body", "type_comment")128 items: list[withitem]129 body: list[stmt]130class AsyncWith(stmt):131 if sys.version_info >= (3, 10):132 __match_args__ = ("items", "body", "type_comment")133 items: list[withitem]134 body: list[stmt]135class Raise(stmt):136 if sys.version_info >= (3, 10):137 __match_args__ = ("exc", "cause")138 exc: expr | None139 cause: expr | None140class Try(stmt):141 if sys.version_info >= (3, 10):142 __match_args__ = ("body", "handlers", "orelse", "finalbody")143 body: list[stmt]144 handlers: list[ExceptHandler]145 orelse: list[stmt]146 finalbody: list[stmt]147if sys.version_info >= (3, 11):148 class TryStar(stmt):149 __match_args__ = ("body", "handlers", "orelse", "finalbody")150 body: list[stmt]151 handlers: list[ExceptHandler]152 orelse: list[stmt]153 finalbody: list[stmt]154class Assert(stmt):155 if sys.version_info >= (3, 10):156 __match_args__ = ("test", "msg")157 test: expr158 msg: expr | None159class Import(stmt):160 if sys.version_info >= (3, 10):161 __match_args__ = ("names",)162 names: list[alias]163class ImportFrom(stmt):164 if sys.version_info >= (3, 10):165 __match_args__ = ("module", "names", "level")166 module: str | None167 names: list[alias]168 level: int169class Global(stmt):170 if sys.version_info >= (3, 10):171 __match_args__ = ("names",)172 names: list[_Identifier]173class Nonlocal(stmt):174 if sys.version_info >= (3, 10):175 __match_args__ = ("names",)176 names: list[_Identifier]177class Expr(stmt):178 if sys.version_info >= (3, 10):179 __match_args__ = ("value",)180 value: expr181class Pass(stmt): ...182class Break(stmt): ...183class Continue(stmt): ...184class expr(AST): ...185class BoolOp(expr):186 if sys.version_info >= (3, 10):187 __match_args__ = ("op", "values")188 op: boolop189 values: list[expr]190class BinOp(expr):191 if sys.version_info >= (3, 10):192 __match_args__ = ("left", "op", "right")193 left: expr194 op: operator195 right: expr196class UnaryOp(expr):197 if sys.version_info >= (3, 10):198 __match_args__ = ("op", "operand")199 op: unaryop200 operand: expr201class Lambda(expr):202 if sys.version_info >= (3, 10):203 __match_args__ = ("args", "body")204 args: arguments205 body: expr206class IfExp(expr):207 if sys.version_info >= (3, 10):208 __match_args__ = ("test", "body", "orelse")209 test: expr210 body: expr211 orelse: expr212class Dict(expr):213 if sys.version_info >= (3, 10):214 __match_args__ = ("keys", "values")215 keys: list[expr | None]216 values: list[expr]217class Set(expr):218 if sys.version_info >= (3, 10):219 __match_args__ = ("elts",)220 elts: list[expr]221class ListComp(expr):222 if sys.version_info >= (3, 10):223 __match_args__ = ("elt", "generators")224 elt: expr225 generators: list[comprehension]226class SetComp(expr):227 if sys.version_info >= (3, 10):228 __match_args__ = ("elt", "generators")229 elt: expr230 generators: list[comprehension]231class DictComp(expr):232 if sys.version_info >= (3, 10):233 __match_args__ = ("key", "value", "generators")234 key: expr235 value: expr236 generators: list[comprehension]237class GeneratorExp(expr):238 if sys.version_info >= (3, 10):239 __match_args__ = ("elt", "generators")240 elt: expr241 generators: list[comprehension]242class Await(expr):243 if sys.version_info >= (3, 10):244 __match_args__ = ("value",)245 value: expr246class Yield(expr):247 if sys.version_info >= (3, 10):248 __match_args__ = ("value",)249 value: expr | None250class YieldFrom(expr):251 if sys.version_info >= (3, 10):252 __match_args__ = ("value",)253 value: expr254class Compare(expr):255 if sys.version_info >= (3, 10):256 __match_args__ = ("left", "ops", "comparators")257 left: expr258 ops: list[cmpop]259 comparators: list[expr]260class Call(expr):261 if sys.version_info >= (3, 10):262 __match_args__ = ("func", "args", "keywords")263 func: expr264 args: list[expr]265 keywords: list[keyword]266class FormattedValue(expr):267 if sys.version_info >= (3, 10):268 __match_args__ = ("value", "conversion", "format_spec")269 value: expr270 conversion: int271 format_spec: expr | None272class JoinedStr(expr):273 if sys.version_info >= (3, 10):274 __match_args__ = ("values",)275 values: list[expr]276if sys.version_info < (3, 8):277 class Num(expr): # Deprecated in 3.8; use Constant278 n: complex279 class Str(expr): # Deprecated in 3.8; use Constant280 s: str281 class Bytes(expr): # Deprecated in 3.8; use Constant282 s: bytes283 class NameConstant(expr): # Deprecated in 3.8; use Constant284 value: Any285 class Ellipsis(expr): ... # Deprecated in 3.8; use Constant286class Constant(expr):287 if sys.version_info >= (3, 10):288 __match_args__ = ("value", "kind")289 value: Any # None, str, bytes, bool, int, float, complex, Ellipsis290 kind: str | None291 # Aliases for value, for backwards compatibility292 s: Any293 n: complex294if sys.version_info >= (3, 8):295 class NamedExpr(expr):296 if sys.version_info >= (3, 10):297 __match_args__ = ("target", "value")298 target: expr299 value: expr300class Attribute(expr):301 if sys.version_info >= (3, 10):302 __match_args__ = ("value", "attr", "ctx")303 value: expr304 attr: _Identifier305 ctx: expr_context306if sys.version_info >= (3, 9):307 _Slice: TypeAlias = expr308else:309 class slice(AST): ...310 _Slice: TypeAlias = slice311class Slice(_Slice):312 if sys.version_info >= (3, 10):313 __match_args__ = ("lower", "upper", "step")314 lower: expr | None315 upper: expr | None316 step: expr | None317if sys.version_info < (3, 9):318 class ExtSlice(slice):319 dims: list[slice]320 class Index(slice):321 value: expr322class Subscript(expr):323 if sys.version_info >= (3, 10):324 __match_args__ = ("value", "slice", "ctx")325 value: expr326 slice: _Slice327 ctx: expr_context328class Starred(expr):329 if sys.version_info >= (3, 10):330 __match_args__ = ("value", "ctx")331 value: expr332 ctx: expr_context333class Name(expr):334 if sys.version_info >= (3, 10):335 __match_args__ = ("id", "ctx")336 id: _Identifier337 ctx: expr_context338class List(expr):339 if sys.version_info >= (3, 10):340 __match_args__ = ("elts", "ctx")341 elts: list[expr]342 ctx: expr_context343class Tuple(expr):344 if sys.version_info >= (3, 10):345 __match_args__ = ("elts", "ctx")346 elts: list[expr]347 ctx: expr_context348 if sys.version_info >= (3, 9):349 dims: list[expr]350class expr_context(AST): ...351if sys.version_info < (3, 9):352 class AugLoad(expr_context): ...353 class AugStore(expr_context): ...354 class Param(expr_context): ...355 class Suite(mod):356 body: list[stmt]357class Del(expr_context): ...358class Load(expr_context): ...359class Store(expr_context): ...360class boolop(AST): ...361class And(boolop): ...362class Or(boolop): ...363class operator(AST): ...364class Add(operator): ...365class BitAnd(operator): ...366class BitOr(operator): ...367class BitXor(operator): ...368class Div(operator): ...369class FloorDiv(operator): ...370class LShift(operator): ...371class Mod(operator): ...372class Mult(operator): ...373class MatMult(operator): ...374class Pow(operator): ...375class RShift(operator): ...376class Sub(operator): ...377class unaryop(AST): ...378class Invert(unaryop): ...379class Not(unaryop): ...380class UAdd(unaryop): ...381class USub(unaryop): ...382class cmpop(AST): ...383class Eq(cmpop): ...384class Gt(cmpop): ...385class GtE(cmpop): ...386class In(cmpop): ...387class Is(cmpop): ...388class IsNot(cmpop): ...389class Lt(cmpop): ...390class LtE(cmpop): ...391class NotEq(cmpop): ...392class NotIn(cmpop): ...393class comprehension(AST):394 if sys.version_info >= (3, 10):395 __match_args__ = ("target", "iter", "ifs", "is_async")396 target: expr397 iter: expr398 ifs: list[expr]399 is_async: int400class excepthandler(AST): ...401class ExceptHandler(excepthandler):402 if sys.version_info >= (3, 10):403 __match_args__ = ("type", "name", "body")404 type: expr | None405 name: _Identifier | None406 body: list[stmt]407class arguments(AST):408 if sys.version_info >= (3, 10):409 __match_args__ = ("posonlyargs", "args", "vararg", "kwonlyargs", "kw_defaults", "kwarg", "defaults")410 if sys.version_info >= (3, 8):411 posonlyargs: list[arg]412 args: list[arg]413 vararg: arg | None414 kwonlyargs: list[arg]415 kw_defaults: list[expr | None]416 kwarg: arg | None417 defaults: list[expr]418class arg(AST):419 if sys.version_info >= (3, 10):420 __match_args__ = ("arg", "annotation", "type_comment")421 arg: _Identifier422 annotation: expr | None423class keyword(AST):424 if sys.version_info >= (3, 10):425 __match_args__ = ("arg", "value")426 arg: _Identifier | None427 value: expr428class alias(AST):429 if sys.version_info >= (3, 10):430 __match_args__ = ("name", "asname")431 name: _Identifier432 asname: _Identifier | None433class withitem(AST):434 if sys.version_info >= (3, 10):435 __match_args__ = ("context_expr", "optional_vars")436 context_expr: expr437 optional_vars: expr | None438if sys.version_info >= (3, 10):439 class Match(stmt):440 __match_args__ = ("subject", "cases")441 subject: expr442 cases: list[match_case]443 class pattern(AST): ...444 # Without the alias, Pyright complains variables named pattern are recursively defined445 _Pattern: TypeAlias = pattern446 class match_case(AST):447 __match_args__ = ("pattern", "guard", "body")448 pattern: _Pattern449 guard: expr | None450 body: list[stmt]451 class MatchValue(pattern):452 __match_args__ = ("value",)453 value: expr454 class MatchSingleton(pattern):455 __match_args__ = ("value",)456 value: Literal[True, False, None]457 class MatchSequence(pattern):458 __match_args__ = ("patterns",)459 patterns: list[pattern]460 class MatchStar(pattern):461 __match_args__ = ("name",)462 name: _Identifier | None463 class MatchMapping(pattern):464 __match_args__ = ("keys", "patterns", "rest")465 keys: list[expr]466 patterns: list[pattern]467 rest: _Identifier | None468 class MatchClass(pattern):469 __match_args__ = ("cls", "patterns", "kwd_attrs", "kwd_patterns")470 cls: expr471 patterns: list[pattern]472 kwd_attrs: list[_Identifier]473 kwd_patterns: list[pattern]474 class MatchAs(pattern):475 __match_args__ = ("pattern", "name")476 pattern: _Pattern | None477 name: _Identifier | None478 class MatchOr(pattern):479 __match_args__ = ("patterns",)...

Full Screen

Full Screen

__version__.py

Source:__version__.py Github

copy

Full Screen

1#2# markdown/__version__.py3#4# version_info should conform to PEP 3865# (major, minor, micro, alpha/beta/rc/final, #)6# (1, 1, 2, 'alpha', 0) => "1.1.2.dev"7# (1, 2, 0, 'beta', 2) => "1.2b2"8version_info = (2, 6, 11, 'final', 0)9def _get_version():10 " Returns a PEP 386-compliant version number from version_info. "11 assert len(version_info) == 512 assert version_info[3] in ('alpha', 'beta', 'rc', 'final')13 parts = 2 if version_info[2] == 0 else 314 main = '.'.join(map(str, version_info[:parts]))15 sub = ''16 if version_info[3] == 'alpha' and version_info[4] == 0:17 # TODO: maybe append some sort of git info here??18 sub = '.dev'19 elif version_info[3] != 'final':20 mapping = {'alpha': 'a', 'beta': 'b', 'rc': 'c'}21 sub = mapping[version_info[3]] + str(version_info[4])22 return str(main + sub)...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run tox automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful