versioning ¤
Utilities to handle different versioning schemes such as SemVer and PEP 440.
Classes:
-
PEP440Bumper
–PEP 440 version bumper.
-
PEP440Version
–PEP 440 version.
-
ParsedVersion
–Base class for versioning schemes.
-
SemVerBumper
–SemVer version bumper.
-
SemVerVersion
–SemVer version.
-
VersionBumper
–Base class for version bumpers.
Functions:
-
parse_pep440
–Parse a PEP version.
-
parse_semver
–Parse a SemVer version.
-
version_prefix
–Return a version and its optional
v
prefix.
Attributes:
-
bump_pep440
–Bump a PEP 440 version.
-
bump_semver
–Bump a SemVer version.
PEP440Bumper ¤
Bases: VersionBumper
PEP 440 version bumper.
Parameters:
Source code in src/git_changelog/versioning.py
650 651 652 653 654 655 656 |
|
PEP440Version ¤
Bases: Version
, ParsedVersion
PEP 440 version.
Methods:
-
bump_alpha
–Bump alpha-release.
-
bump_beta
–Bump beta-release.
-
bump_candidate
–Bump candidate release.
-
bump_dev
–Bump dev-release.
-
bump_epoch
–Bump epoch.
-
bump_major
–Bump major.
-
bump_micro
–Bump micro.
-
bump_minor
–Bump minor.
-
bump_post
–Bump post-release.
-
bump_pre
–Bump pre-release.
-
bump_release
–Bump given release level.
-
dent_alpha
–Dent to alpha-release.
-
dent_beta
–Dent to beta-release.
-
dent_candidate
–Dent to candidate release.
-
dent_dev
–Dent to dev-release.
-
dent_pre
–Dent to pre-release.
-
from_parts
–Build a version from its parts.
bump_alpha ¤
bump_alpha() -> PEP440Version
Bump alpha-release.
Examples:
>>> PEP440Version("1").bump_alpha()
ValueError: Cannot bump from release to alpha pre-release (use `dent_alpha`)
>>> PEP440Version("1a0").bump_alpha()
<Version('1a1')>
>>> PEP440Version("1a0").bump_alpha("a")
<Version('1a1')>
>>> PEP440Version("1a0.post0").bump_alpha()
<Version('1a1')>
Returns:
-
PEP440Version
–Version with same epoch, same release, bumped alpha pre-release and the right parts reset to 0 or nothing.
Source code in src/git_changelog/versioning.py
381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 |
|
bump_beta ¤
bump_beta() -> PEP440Version
Bump beta-release.
Examples:
>>> PEP440Version("1").bump_beta()
ValueError: Cannot bump from release to beta pre-release (use `dent_beta`)
>>> PEP440Version("1b0").bump_beta()
<Version('1b1')>
>>> PEP440Version("1b0").bump_beta()
<Version('1b1')>
>>> PEP440Version("1b0.post0").bump_beta()
<Version('1b1')>
Returns:
-
PEP440Version
–Version with same epoch, same release, bumped beta pre-release and the right parts reset to 0 or nothing.
Source code in src/git_changelog/versioning.py
399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 |
|
bump_candidate ¤
bump_candidate() -> PEP440Version
Bump candidate release.
Examples:
>>> PEP440Version("1").bump_candidate()
ValueError: Cannot bump from release to candidate pre-release (use `dent_candidate`)
>>> PEP440Version("1c0").bump_candidate()
<Version('1rc1')>
>>> PEP440Version("1c0").bump_candidate()
<Version('1rc1')>
>>> PEP440Version("1c0.post0").bump_candidate()
<Version('1rc1')>
Returns:
-
PEP440Version
–Version with same epoch, same release, bumped candidate pre-release and the right parts reset to 0 or nothing.
Source code in src/git_changelog/versioning.py
417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 |
|
bump_dev ¤
bump_dev() -> PEP440Version
Bump dev-release.
Examples:
>>> PEP440Version("1").bump_dev()
ValueError: Cannot bump from release to dev-release (use `dent_dev`)
>>> PEP440Version("1a0").bump_dev()
ValueError: Cannot bump from alpha to dev-release (use `dent_dev`)
>>> PEP440Version("1b1").bump_dev()
ValueError: Cannot bump from beta to dev-release (use `dent_dev`)
>>> PEP440Version("1rc2").bump_dev()
ValueError: Cannot bump from candidate to dev-release (use `dent_dev`)
>>> PEP440Version("1.post0").bump_dev()
ValueError: Cannot bump from post to dev-release (use `dent_dev`)
>>> PEP440Version("1a0.dev1").bump_dev()
<Version('1a0.dev2')>
Returns:
-
PEP440Version
–Version with same epoch, same release, same pre-release, same post-release and bumped dev-release.
Source code in src/git_changelog/versioning.py
454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 |
|
bump_epoch ¤
bump_epoch() -> PEP440Version
Bump epoch.
Examples:
>>> PEP440Version("1.0").bump_epoch()
<Version('1!1.0')>
>>> PEP440Version("0!1.0").bump_epoch()
<Version('1!1.0')>
>>> PEP440Version("1!1.0").bump_epoch()
<Version('2!1.0')>
>>> PEP440Version("1.0a2.post3").bump_epoch()
<Version('2!1.0')>
Returns:
-
PEP440Version
–Version with bumped epoch, same release, and the right parts reset to 0 or nothing.
Source code in src/git_changelog/versioning.py
142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 |
|
bump_major ¤
bump_major(*, trim: bool = False) -> PEP440Version
Bump major.
Parameters:
-
trim
(bool
, default:False
) –Whether to trim all zeroes on the right after bumping.
Examples:
>>> PEP440Version("1").bump_major()
<Version('2')>
>>> PEP440Version("1.1").bump_major()
<Version('2.0')>
>>> PEP440Version("1.1.1").bump_major()
<Version('2.0.0')>
>>> PEP440Version("1.1.1").bump_major(trim=True)
<Version('2')>
>>> PEP440Version("1a2.post3").bump_major()
<Version('2')>
Returns:
-
PEP440Version
–Version with same epoch, bumped major and the right parts reset to 0 or nothing.
Source code in src/git_changelog/versioning.py
244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 |
|
bump_micro ¤
bump_micro(*, trim: bool = False) -> PEP440Version
Bump micro.
Parameters:
-
trim
(bool
, default:False
) –Whether to trim all zeroes on the right after bumping.
Examples:
>>> PEP440Version("1").bump_micro()
<Version('1.0.1')>
>>> PEP440Version("1.1").bump_micro()
<Version('1.1.1')>
>>> PEP440Version("1.1.1").bump_micro()
<Version('1.1.2')>
>>> PEP440Version("1.1.1").bump_micro()
<Version('1.1.2')>
>>> PEP440Version("1.1.1.1").bump_micro()
<Version('1.1.2.0')>
>>> PEP440Version("1.1.1.1").bump_micro(trim=True)
<Version('1.1.2')>
>>> PEP440Version("1a2.post3").bump_micro()
<Version('1.0.1')>
Returns:
-
PEP440Version
–Version with same epoch, same major, same minor, bumped micro and the right parts reset to 0 or nothing.
Source code in src/git_changelog/versioning.py
290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 |
|
bump_minor ¤
bump_minor(*, trim: bool = False) -> PEP440Version
Bump minor.
Parameters:
-
trim
(bool
, default:False
) –Whether to trim all zeroes on the right after bumping.
Examples:
>>> PEP440Version("1").bump_minor()
<Version('1.1')>
>>> PEP440Version("1.1").bump_minor()
<Version('1.2')>
>>> PEP440Version("1.1.1").bump_minor()
<Version('1.2.0')>
>>> PEP440Version("1.1.1").bump_minor(trim=True)
<Version('1.2')>
>>> PEP440Version("1a2.post3").bump_minor()
<Version('1.1')>
Returns:
-
PEP440Version
–Version with same epoch, same major, bumped minor and the right parts reset to 0 or nothing.
Source code in src/git_changelog/versioning.py
267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 |
|
bump_post ¤
bump_post() -> PEP440Version
Bump post-release.
Examples:
>>> PEP440Version("1").bump_post()
<Version('1.post0')>
>>> PEP440Version("1.post0").bump_post()
<Version('1.post1')>
>>> PEP440Version("1a0.post0").bump_post()
<Version('1a0.post1')>
>>> PEP440Version("1.post0.dev1").bump_post()
<Version('1.post1')>
Returns:
-
PEP440Version
–Version with same epoch, same release, same pre-release, bumped post-release and the right parts reset to 0 or nothing.
Source code in src/git_changelog/versioning.py
435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 |
|
bump_pre ¤
bump_pre(
pre: Literal["a", "b", "c", "rc"] | None = None
) -> PEP440Version
Bump pre-release.
Parameters:
-
pre
(Literal['a', 'b', 'c', 'rc'] | None
, default:None
) –Kind of pre-release to bump.
- a means alpha
- b means beta
- c or rc means (release) candidate
Examples:
>>> PEP440Version("1").bump_pre()
ValueError: Cannot bump from release to alpha pre-release (use `dent_pre`)
>>> PEP440Version("1a0").bump_pre()
<Version('1a1')>
>>> PEP440Version("1a0").bump_pre("a")
<Version('1a1')>
>>> PEP440Version("1a0.post0").bump_pre()
<Version('1a1')>
>>> PEP440Version("1b2").bump_pre("a")
ValueError: Cannot bump from beta to alpha pre-release (use `dent_alpha`)
>>> PEP440Version("1c2").bump_pre("a")
ValueError: Cannot bump from candidate to alpha pre-release (use `dent_alpha`)
>>> PEP440Version("1").bump_pre("b")
ValueError: Cannot bump from release to beta pre-release (use `dent_beta`)
>>> PEP440Version("1a2").bump_pre("b")
<Version('1b0')>
>>> PEP440Version("1b2").bump_pre("b")
<Version('1b3')>
>>> PEP440Version("1c2").bump_pre("b")
ValueError: Cannot bump from candidate to beta pre-release (use `dent_beta`)
>>> PEP440Version("1").bump_pre("c")
ValueError: Cannot bump from release to candidate pre-release (use `dent_candidate`)
>>> PEP440Version("1a2").bump_pre("c")
<Version('1rc0')>
>>> PEP440Version("1b2").bump_pre("rc")
<Version('1rc0')>
>>> PEP440Version("1rc2").bump_pre("c")
<Version('1rc3')>
Returns:
-
PEP440Version
–Version with same epoch, same release, bumped pre-release and the right parts reset to 0 or nothing.
Source code in src/git_changelog/versioning.py
317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 |
|
bump_release ¤
bump_release(
level: int | None = None, *, trim: bool = False
) -> PEP440Version
Bump given release level.
Parameters:
-
level
(int | None
, default:None
) –The release level to bump.
- 0 means major
- 1 means minor
- 2 means micro (patch)
- 3+ don't have names
- None means move from pre-release to release (unchanged)
-
trim
(bool
, default:False
) –Whether to trim all zeroes on the right after bumping.
Examples:
>>> PEP440Version("1").bump_release(0)
<Version('2')>
>>> PEP440Version("1.1").bump_release(0)
<Version('2.0')>
>>> PEP440Version("1.1.1").bump_release(0)
<Version('2.0.0')>
>>> PEP440Version("1.1.1").bump_release(0, trim=True)
<Version('2')>
>>> PEP440Version("1a2.post3").bump_release(0)
<Version('2')>
>>> PEP440Version("1").bump_release(1)
<Version('1.1')>
>>> PEP440Version("1.1").bump_release(1)
<Version('1.2')>
>>> PEP440Version("1.1.1").bump_release(1)
<Version('1.2.0')>
>>> PEP440Version("1.1.1").bump_release(1, trim=True)
<Version('1.2')>
>>> PEP440Version("1a2.post3").bump_release(1)
<Version('1.1')>
>>> PEP440Version("1a0").bump_release()
<Version('1')>
>>> PEP440Version("1b1").bump_release()
<Version('1')>
>>> PEP440Version("1rc2").bump_release()
<Version('1')>
>>> PEP440Version("1a2.dev0").bump_release()
<Version('1')>
>>> PEP440Version("1post0").bump_release()
ValueError: Cannot bump from post-release to release
Returns:
-
PEP440Version
–Version with same epoch, bumped release level, and the right parts reset to 0 or nothing.
Source code in src/git_changelog/versioning.py
160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 |
|
dent_alpha ¤
dent_alpha() -> PEP440Version
Dent to alpha-release.
Examples:
>>> PEP440Version("1").dent_alpha()
<Version('1a0')>
>>> PEP440Version("1a0").dent_alpha()
ValueError: Cannot dent alpha pre-releases
>>> PEP440Version("1b0").dent_alpha()
ValueError: Cannot dent beta pre-releases
>>> PEP440Version("1rc0").dent_alpha()
ValueError: Cannot dent candidate pre-releases
Returns:
-
PEP440Version
–Version with same epoch and release dented to alpha pre-release.
Source code in src/git_changelog/versioning.py
529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 |
|
dent_beta ¤
dent_beta() -> PEP440Version
Dent to beta-release.
Examples:
>>> PEP440Version("1").dent_beta()
<Version('1b0')>
>>> PEP440Version("1a0").dent_beta()
ValueError: Cannot dent alpha pre-releases
>>> PEP440Version("1b0").dent_beta()
ValueError: Cannot dent beta pre-releases
>>> PEP440Version("1rc0").dent_beta()
ValueError: Cannot dent candidate pre-releases
Returns:
-
PEP440Version
–Version with same epoch and release dented to beta pre-release.
Source code in src/git_changelog/versioning.py
547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 |
|
dent_candidate ¤
dent_candidate() -> PEP440Version
Dent to candidate release.
Examples:
>>> PEP440Version("1").dent_candidate()
<Version('1rc0')>
>>> PEP440Version("1a0").dent_candidate()
ValueError: Cannot dent alpha pre-releases
>>> PEP440Version("1b0").dent_candidate()
ValueError: Cannot dent beta pre-releases
>>> PEP440Version("1rc0").dent_candidate()
ValueError: Cannot dent candidate pre-releases
Returns:
-
PEP440Version
–Version with same epoch and release dented to candidate pre-release.
Source code in src/git_changelog/versioning.py
565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 |
|
dent_dev ¤
dent_dev() -> PEP440Version
Dent to dev-release.
Examples:
>>> PEP440Version("1").dent_dev()
<Version('1.dev0')>
>>> PEP440Version("1a0").dent_dev()
<Version('1a0.dev0')>
>>> PEP440Version("1b1").dent_dev()
<Version('1b1.dev0')>
>>> PEP440Version("1c2").dent_dev()
<Version('1rc2.dev0')>
>>> PEP440Version("1.post0").dent_dev()
<Version('1.post0.dev0')>
>>> PEP440Version("1a0.dev1").dent_dev()
ValueError: Cannot dent dev-releases
Returns:
-
PEP440Version
–Version with same epoch and release dented to dev-release.
Source code in src/git_changelog/versioning.py
583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 |
|
dent_pre ¤
dent_pre(
pre: Literal["a", "b", "c", "rc"] | None = None
) -> PEP440Version
Dent to pre-release.
This method dents a release down to an alpha, beta or candidate pre-release.
Parameters:
-
pre
(Literal['a', 'b', 'c', 'rc'] | None
, default:None
) –Kind of pre-release to bump.
- a means alpha
- b means beta
- c or rc means (release) candidate
Examples:
>>> PEP440Version("1").dent_pre()
<Version('1a0')>
>>> PEP440Version("1").dent_pre("a")
<Version('1a0')>
>>> PEP440Version("1a0").dent_pre("a")
ValueError: Cannot dent alpha pre-releases
>>> PEP440Version("1").dent_pre("b")
<Version('1b0')>
>>> PEP440Version("1b0").dent_pre("b")
ValueError: Cannot dent beta pre-releases
>>> PEP440Version("1").dent_pre("c")
<Version('1rc0')>
>>> PEP440Version("1").dent_pre("rc")
<Version('1rc0')>
>>> PEP440Version("1rc0").dent_pre("c")
ValueError: Cannot dent candidate pre-releases
Returns:
-
PEP440Version
–Version with same epoch and release dented to pre-release.
Source code in src/git_changelog/versioning.py
490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 |
|
from_parts classmethod
¤
from_parts(
epoch: int | None = None,
release: tuple[int, ...] | None = None,
pre: tuple[str, int] | None = None,
post: int | None = None,
dev: int | None = None,
) -> PEP440Version
Build a version from its parts.
Parameters:
-
epoch
(int | None
, default:None
) –Version's epoch number.
-
release
(tuple[int, ...] | None
, default:None
) –Version's release numbers.
-
pre
(tuple[str, int] | None
, default:None
) –Version's prerelease kind and number.
-
post
(int | None
, default:None
) –Version's post number.
-
dev
(int | None
, default:None
) –Version's dev number.
Returns:
-
PEP440Version
–A PEP 440 version.
Source code in src/git_changelog/versioning.py
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 |
|
SemVerBumper ¤
Bases: VersionBumper
SemVer version bumper.
Parameters:
Source code in src/git_changelog/versioning.py
650 651 652 653 654 655 656 |
|
SemVerVersion ¤
Bases: Version
, ParsedVersion
SemVer version.
Methods:
-
bump_release
–Bump from a pre-release to the same, regular release.
bump_release ¤
bump_release() -> SemVerVersion
Bump from a pre-release to the same, regular release.
Returns:
-
SemVerVersion
–The same version, without pre-release or build metadata.
Source code in src/git_changelog/versioning.py
82 83 84 85 86 87 88 |
|
VersionBumper ¤
Base class for version bumpers.
Parameters:
Source code in src/git_changelog/versioning.py
650 651 652 653 654 655 656 |
|
parse_pep440 ¤
parse_pep440(version: str) -> tuple[PEP440Version, str]
Parse a PEP version.
Returns:
-
tuple[PEP440Version, str]
–A PEP 440 version instance with useful methods.
Source code in src/git_changelog/versioning.py
635 636 637 638 639 640 641 642 |
|
parse_semver ¤
parse_semver(version: str) -> tuple[SemVerVersion, str]
Parse a SemVer version.
Returns:
-
tuple[SemVerVersion, str]
–A semver version instance with useful methods.
Source code in src/git_changelog/versioning.py
625 626 627 628 629 630 631 632 |
|
version_prefix ¤
Return a version and its optional v
prefix.
Parameters:
-
version
(str
) –The full version.
Returns:
Source code in src/git_changelog/versioning.py
608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 |
|