Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PYG-197] 🖌 Style fixes typed #271

Merged
merged 3 commits into from
Aug 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 8 additions & 12 deletions cognite/pygen/_core/templates/typed_classes.py.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,9 @@ class {{ cls.typed_properties_name }}:{% for field in cls.container_fields_sort
class {{ cls.read_name }}Apply({{ cls.typed_properties_name }}, {{ cls.typed_write_bases_classes }}):
"""This represents the writing format of {{ cls.doc_name }}.

It is used to when data is written to CDF.{% if cls.description %}

It is used to when data is written to CDF.
{% if cls.description %}
{{ cls.description }}{% endif %}

Args:
space: The space where the node is located.
external_id: The external id of the {{ cls.doc_name }}.{% for field in cls.container_fields_sorted() %}
Expand Down Expand Up @@ -58,10 +57,9 @@ class {{ cls.read_name }}Apply({{ cls.typed_properties_name }}, {{ cls.typed_wri
class {{ cls.read_name }}({{ cls.typed_properties_name }}, {{ cls.typed_read_bases_classes }}):
"""This represents the reading format of {{ cls.doc_name }}.

It is used to when data is read from CDF.{% if cls.description %}

It is used to when data is read from CDF.
{% if cls.description %}
{{ cls.description }}{% endif %}

Args:
space: The space where the node is located.
external_id: The external id of the {{ cls.doc_name }}.
Expand Down Expand Up @@ -112,10 +110,9 @@ class {{ cls.typed_properties_name }}:{% for field in cls.container_fields_sort
class {{ cls.read_name }}Apply({{ cls.typed_properties_name }}, {{ cls.typed_write_bases_classes }}):
"""This represents the writing format of {{ cls.doc_name }}.

It is used to when data is written to CDF.{% if cls.description %}

It is used to when data is written to CDF.
{% if cls.description %}
{{ cls.description }}{% endif %}

Args:
space: The space where the node is located.
external_id: The external id of the {{ cls.doc_name }}.
Expand Down Expand Up @@ -150,10 +147,9 @@ class {{ cls.read_name }}Apply({{ cls.typed_properties_name }}, {{ cls.typed_wri
class {{ cls.read_name }}({{ cls.typed_properties_name }}, {{ cls.typed_read_bases_classes }}):
"""This represents the reading format of {{ cls.doc_name }}.

It is used to when data is read from CDF.{% if cls.description %}

It is used to when data is read from CDF.
{% if cls.description %}
{{ cls.description }}{% endif %}

Args:
space: The space where the node is located.
external_id: The external id of the {{ cls.doc_name }}.
Expand Down
10 changes: 9 additions & 1 deletion cognite/pygen/utils/text.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,9 +210,17 @@ def to_words(string: str, pluralize: bool = False, singularize: bool = False):
>>> to_words('APM_Activities', singularize=True)
'apm activity'
"""
return to_snake(string, pluralize, singularize).replace("_", " ")
words = to_snake(string, pluralize, singularize).replace("_", " ")
for word, fix in _SPECIAL_WORD_FIXES.items():
words = words.replace(word, fix)
return words


_SPECIAL_WORD_FIXES = {
"cognite": "Cognite",
" 3 d ": " 3D ",
}

# These are words which are not pluralized as we want to by inflect
# Fox example, "person" becomes "people" instead of "persons", which is more grammatically correct, however,
# "persons" is more consistent with the rest of the API.
Expand Down