Introduction
This project provides a Python data model for creating and manipulating UML diagrams. It is the foundational data model for the UML Shapes module.
Installation
It is recommended to use a virtual environment for installing Python packages.
# Create and activate a virtual environment
python -m venv venv
source venv/bin/activate
# Install the package
pip install umlmodel
Usage
Programmatic Usage
The umlmodel library allows you to create UML elements like classes, interfaces, and use cases programmatically. Here are some examples:
Creating a Class
To create a simple class, instantiate the Class object:
from umlmodel.Class import Class
modelClass: Class = Class(name='MyClass')
print(modelClass.name)
Adding Fields to a Class
You can add fields (attributes) to a class. Fields have a name, type, visibility, and an optional default value.
from umlmodel.Class import Class
from umlmodel.Field import Field
from umlmodel.FieldType import FieldType
from umlmodel.enumerations.Visibility import Visibility
# Create a class
modelClass: Class = Class(name='MyClass')
# Create fields
field1: Field = Field(name='my_string',
type=FieldType('str'),
visibility=Visibility.PUBLIC,
defaultValue='"hello"')
field2: Field = Field(name='_my_private_int',
type=FieldType('int'),
visibility=Visibility.PRIVATE)
# Add fields to the class
modelClass.fields.append(field1)
modelClass.fields.append(field2)
# The string representation of a field is useful
print(field1)
print(field2)
Adding Methods to a Class
Methods can be added to a class, including parameters and return types.
from umlmodel.Class import Class
from umlmodel.Method import Method
from umlmodel.Parameter import Parameter
from umlmodel.ParameterType import ParameterType
from umlmodel.ReturnType import ReturnType
from umlmodel.enumerations.Visibility import Visibility
# Create a class
modelClass: Class = Class(name='MyClass')
# Create a method
method: Method = Method(name='my_method', visibility=Visibility.PUBLIC)
# Add a parameter
parameter: Parameter = Parameter(name='value', type=ParameterType('int'), defaultValue='0')
method.addParameter(parameter)
# Set a return type
method.returnType = ReturnType('bool')
# Add the method to the class
modelClass.methods.append(method)
# Print the method signature
print(method.methodWithParameters())
Written by Humberto A. Sanchez II (C) 2026
Note
For all kinds of problems, requests, enhancements, bug reports, etc., please drop me an e-mail.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file umlmodel-3.5.0.tar.gz.
File metadata
- Download URL: umlmodel-3.5.0.tar.gz
- Upload date:
- Size: 24.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8db3b3c6a5e76964e825a216de09f6009179fb0380c73a83cb4e48d7b9462614
|
|
| MD5 |
c8048afb6961c9d6b0ab24bdc4692fd8
|
|
| BLAKE2b-256 |
a7f87c7ef3f22d0053cbbf5a4d2fac9e0fccbe5ba9c306c6675c214082f7fb79
|
Provenance
The following attestation bundles were made for umlmodel-3.5.0.tar.gz:
Publisher:
python-publish.yml on hasii2011/umlmodel
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
umlmodel-3.5.0.tar.gz -
Subject digest:
8db3b3c6a5e76964e825a216de09f6009179fb0380c73a83cb4e48d7b9462614 - Sigstore transparency entry: 2540145291
- Sigstore integration time:
-
Permalink:
hasii2011/umlmodel@a43ce290928ea92edb5788cf9c4660309aad88ec -
Branch / Tag:
refs/tags/3.5.0 - Owner: https://github.com/hasii2011
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@a43ce290928ea92edb5788cf9c4660309aad88ec -
Trigger Event:
release
-
Statement type:
File details
Details for the file umlmodel-3.5.0-py3-none-any.whl.
File metadata
- Download URL: umlmodel-3.5.0-py3-none-any.whl
- Upload date:
- Size: 30.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d51b9876aa1b3bb5b437914b63d1cdd25639e5bef675560309914b98cb90226b
|
|
| MD5 |
bbdb7cdaa0a4fdeca59fcedfb91d2f2d
|
|
| BLAKE2b-256 |
ecd8b0af0a2360ff50cef78de15355de87e56b4416c4369ced40a012504b5875
|
Provenance
The following attestation bundles were made for umlmodel-3.5.0-py3-none-any.whl:
Publisher:
python-publish.yml on hasii2011/umlmodel
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
umlmodel-3.5.0-py3-none-any.whl -
Subject digest:
d51b9876aa1b3bb5b437914b63d1cdd25639e5bef675560309914b98cb90226b - Sigstore transparency entry: 2540145535
- Sigstore integration time:
-
Permalink:
hasii2011/umlmodel@a43ce290928ea92edb5788cf9c4660309aad88ec -
Branch / Tag:
refs/tags/3.5.0 - Owner: https://github.com/hasii2011
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@a43ce290928ea92edb5788cf9c4660309aad88ec -
Trigger Event:
release
-
Statement type: