Skip to main content

Python Source Code Types For Inline Syntax Highlighting

The original Python Inline Source by Sam Willis is no longer maintained. Please raise your issues and questions in jurooravec/python-inline-source-2.

The PyPI package and VSCode extension have also been migrated:

This fork is based on v0.0.4.

Type annotations for various languages, when applied to multi line strings will syntax highlighting with the python-inline-source-2 VS Code plugin.

Supports html, css, javascript, typescript, sql, graphql, multiple css extension languages, template languages and many more, see below for a full list.

Uses typing.Annotated to annotate the str type with the language used. You can use typing.get_type_hints at runtime to determine the language that a string has been annotated with.

On Python versions prior to 3.9 uses typing_extensions to support Annotated types.

Installation

pip install sourcetypes2

Example

Example

Usage

Use a type decoration named for language that you are using:

import sourcetypes

my_html_string: sourcetypes.html = """
  <h1>Some HTML</h1>
"""

or:

from sourcetypes import html

my_html_string: html = """
  <h1>Some HTML</h1>
"""

Supported Languages

  • markdown (aliased as md)
  • html
  • django_html (aliased as django)
  • django_txt
  • jinja
  • jinja_html
  • css (aliased as style, and styles)
  • scss
  • less
  • sass
  • stylus
  • javascript (aliased as js)
  • jsx (aliased as javascriptreact, and react)
  • typescript (aliased as ts)
  • tsx (aliased as typescriptreact)
  • coffeescript (aliased as coffee)
  • sql
  • json
  • yaml
  • graphql
  • xml
  • python

Release Notes

[0.0.5] - 2024-10-17

  • Add py.typed. #4

[0.0.4] - 2024-10-17

  • Forked from v0.0.4

Dev notes

Install twine and build

pip install twine build

Packaging:

python -m build --sdist --wheel --outdir dist/ .

Publishing:

twine upload --repository pypi dist/* -u __token__ -p <pypi-token>

Metadata

Release files for sourcetypes2 0.0.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sourcetypes2 0.0.5
File Size Uploaded Provenance
sourcetypes2-0.0.5.tar.gz 3.6 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for sourcetypes2 0.0.5
File Interpreter ABI Platform
sourcetypes2-0.0.5-py3-none-any.whl Python 3 none any Details

Total release size: 7.5 kB

Release files / sourcetypes2-0.0.5.tar.gz

Download URL sourcetypes2-0.0.5.tar.gz
Size 3.6 kB
Tags Source
SHA-256 checksum
How to use checksums
6d37f8bb1a7bc05891a2c5d3a22f7ba54f734126e261df9faac3bd00dbf76b77
BLAKE2b-256 checksum
How to use checksums
c70165372d32e6a3362ff78311a2e8c3963a338cc0b4be7a2c22bff2e28d7535
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.11.5

Release files / sourcetypes2-0.0.5-py3-none-any.whl

Download URL sourcetypes2-0.0.5-py3-none-any.whl
Size 3.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7b585fdc9d444ae8d4855bac96906c73f3551a387bde667f588440ec978379dc
BLAKE2b-256 checksum
How to use checksums
d6114dfedddac39c11d064e2954f99fde452b0a0b1d1a4438feee41f4411e171
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.11.5

Security for sourcetypes2 0.0.5

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Release history Release notifications | RSS feed

This release

0.0.5 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page