Skip to content

Commit db1e569

Browse files
author
Nicholas Long
committed
Merge remote-tracking branch 'origin/develop' into abstract-out-modelica-version
2 parents 0e6fd9e + 787f5b2 commit db1e569

9 files changed

Lines changed: 685 additions & 729 deletions

File tree

.github/workflows/ci.yml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99
fail-fast: false
1010
matrix:
1111
os: [ubuntu-latest]
12-
python-version: ["3.9", "3.13"]
12+
python-version: ["3.10", "3.13"]
1313
runs-on: ${{ matrix.os }}
1414
steps:
1515
- uses: actions/checkout@v6
@@ -18,10 +18,7 @@ jobs:
1818
with:
1919
python-version: ${{ matrix.python-version }}
2020
- name: Install Poetry
21-
# Use Poetry 2.2.1 for Python 3.9 compatibility
2221
uses: Gr1N/setup-poetry@v9
23-
with:
24-
poetry-version: "2.2.1"
2522
- name: Install dependencies with Poetry
2623
# poetry setuptools workaround sourced from:
2724
# https://github.com/python-poetry/poetry/issues/7611#issuecomment-1711443539
@@ -32,6 +29,14 @@ jobs:
3229
3330
# Install twine to test build
3431
python -m pip install build twine
32+
- name: Install modelicafmt
33+
env:
34+
MODELICA_FMT_VERSION: v0.3.1
35+
run: |
36+
curl -SLO "https://github.com/urbanopt/modelica-fmt/releases/download/${MODELICA_FMT_VERSION}/modelica-fmt_Linux_x86_64.tar.gz"
37+
tar --exclude='README.md' --exclude='CHANGELOG.md' -xzf modelica-fmt_Linux_x86_64.tar.gz
38+
chmod +x modelicafmt
39+
sudo mv modelicafmt /usr/local/bin/
3540
- name: Run pre-commit
3641
run: poetry run pre-commit run --all-files
3742
- name: Build docs

.pre-commit-config.yaml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
exclude: |
22
(?x)(
33
^docs/conf.py|
4-
^modelica_builder/modelica_parser/
4+
^modelica_builder/modelica_parser/|
5+
^tests/data/
56
)
67
78
repos:
@@ -48,6 +49,15 @@ repos:
4849
- id: flake8
4950
args:
5051
["--ignore=F401,E402,E501,E731,W503,W504", "--max-line-length=100"]
52+
- repo: local
53+
hooks:
54+
- id: modelica-fmt
55+
name: Modelica Formatter
56+
types: [file]
57+
files: \.(mo|mot|mopt)$
58+
entry: modelicafmt
59+
args: ["-w", "-wrap-arrays"]
60+
language: system
5161
- repo: https://github.com/pre-commit/mirrors-prettier
5262
rev: v4.0.0-alpha.8
5363
hooks:

modelica_builder/modelica_parser/utils.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33

44

55
import sys
6-
7-
from antlr4 import FileStream, CommonTokenStream
6+
from antlr4 import CommonTokenStream, FileStream
87
from antlr4.error.ErrorListener import ErrorListener
98
from antlr4.tree.Tree import TerminalNodeImpl
109

modelica_builder/modelica_project.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ def _load_data(self) -> None:
108108
patterns = []
109109
with open(project_ignore_file) as f:
110110
patterns = f.read().splitlines()
111-
spec = pathspec.PathSpec.from_lines(pathspec.patterns.GitWildMatchPattern, patterns)
111+
spec = pathspec.GitIgnoreSpec.from_lines(patterns)
112112
else:
113113
spec = None
114114

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
within {{within}};
22
package {{name}}
33
extends Modelica.Icons.Package;
4-
54
end {{name}};
Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
package {{name}}
22
extends Modelica.Icons.Package;
3-
4-
annotation (uses(
5-
Modelica(version="{{modelica_version}}"), Buildings(version="{{mbl_version}}")), version="1");
3+
annotation (
4+
uses(
5+
Modelica(
6+
version="4.0.0"),
7+
Buildings(
8+
version="{{mbl_version}}")),
9+
version="1");
610
end {{name}};

poetry.lock

Lines changed: 644 additions & 708 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ classifiers = [
1919
"Intended Audience :: Developers",
2020
"Intended Audience :: Science/Research",
2121
"Topic :: Scientific/Engineering",
22-
"Programming Language :: Python :: 3.9",
2322
"Programming Language :: Python :: 3.10",
2423
"Programming Language :: Python :: 3.11",
2524
"Programming Language :: Python :: 3.12",
@@ -29,25 +28,25 @@ classifiers = [
2928
[tool.poetry.dependencies]
3029
# Urbanopt SDK requires Python 3.10 as of UOv0.9.0
3130
# https://python-poetry.org/docs/dependency-specification/
32-
python = ">=3.9, <3.14"
31+
python = ">=3.10, <3.14"
3332
antlr4-python3-runtime = "4.13.2"
3433
jinja2 = "~3.1.4"
35-
pathspec = ">=0.11.2,<1.1.0"
34+
pathspec = ">=0.11.2,<1.2.0"
3635
certifi = ">=2024.8.30,<2027.0.0"
3736

3837
[tool.poetry.group.dev.dependencies]
3938
autopep8 = "~2.3"
40-
coveralls = ">=3.3,<4.1"
41-
mypy = ">=1.18,<1.20"
42-
pre-commit = "~4.3"
43-
pytest = "~8.4"
39+
coveralls = ">=3.3,<4.2"
40+
mypy = ">=1.18,<2.4"
41+
pre-commit = "~4.6"
42+
pytest = "~9.1"
4443
pytest-cov = ">=5.0,<7.2"
4544
pytest-benchmark = "~5.2.3"
4645
# don't update sphinx right now
4746
sphinx = "~7.4"
4847
sphinx_rtd_theme = ">=3.0,<3.2"
4948
sphinx-jsonschema = "~1.19"
50-
syrupy = "~4.9"
49+
syrupy = "~5.5"
5150
toml = "~0.10"
5251

5352
[build-system]

tests/test_package_parser.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# See also https://github.com/urbanopt/modelica-builder/blob/develop/LICENSE.md
33

44
import os
5+
import re
56
import shutil
67
import unittest
78
from pathlib import Path
@@ -56,7 +57,10 @@ def test_mbl_version(self):
5657
# check for strings in files
5758
with open(Path(self.output_dir) / 'package.mo') as f:
5859
file_data = f.read()
59-
self.assertTrue('Buildings(version="2.0.0"' in file_data, 'Incorrect mbl_version')
60+
self.assertTrue(
61+
re.search(r'Buildings\(\s*version="2\.0\.0"', file_data),
62+
'Incorrect mbl_version',
63+
)
6064

6165
def test_modelica_version_default(self):
6266
# verify backwards compatibility: when modelica_version isn't provided, default to 4.0.0

0 commit comments

Comments
 (0)