Skip to content

Conversation

@cesarcoatl
Copy link
Member

@cesarcoatl cesarcoatl commented Jan 20, 2026

Summary by Sourcery

Align OPC and Jython script abstractions with updated typing expectations and stub definitions.

Enhancements:

  • Make OPC browse element property accessors abstract to better reflect their intended interface.
  • Align AbstractMutableJythonMap.setitem parameter naming between implementation and type stubs for consistent type checking.

@sourcery-ai
Copy link

sourcery-ai bot commented Jan 20, 2026

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Refactors type-related interfaces by aligning method signatures and type hints between runtime code and stubs, and temporarily stubs out two OPC browse element property accessors that were causing type-checking issues.

Class diagram for updated AbstractMutableJythonMap type signatures

classDiagram
    class PyObject

    class MutableJythonMap

    class AbstractMutableJythonMap {
        +get(self, pyKey: PyObject, def_: PyObject) PyObject
        +update(self, args: PyObject, kwargs: Union~str,unicode~) None
        +__setitem__(self, pyKey: PyObject, pyValue: PyObject) None
        +__delitem__(self, pyKey: PyObject) None
    }

    AbstractMutableJythonMap --|> MutableJythonMap
    AbstractMutableJythonMap ..> PyObject
Loading

Class diagram for OPC BrowseElement property accessors after refactor

classDiagram
    class BrowseElement {
        +getItemType(self)
        +getProperties(self) List~BrowseElement.PropertyElement~
        +getProperty(self, id_: int) BrowseElement.PropertyElement
        +getServer(self) Union~str,unicode~
    }

    class PropertyElement

    BrowseElement o-- PropertyElement
Loading

File-Level Changes

Change Details Files
Temporarily disable OPC browse element property accessors that caused type errors.
  • Replace getProperties implementation with a placeholder body that does nothing (pass) while retaining its return type annotation.
  • Replace getProperty implementation with a placeholder body that does nothing (pass) while retaining its parameter and return type annotations.
src/com/inductiveautomation/ignition/common/opc/__init__.py
Align AbstractMutableJythonMap setitem parameter naming between implementation and stub.
  • Rename second parameter of setitem from value to pyValue to be consistent with surrounding naming conventions and type hints.
  • Mirror the same parameter rename in the corresponding stub file so runtime and stub signatures match for type checking.
src/com/inductiveautomation/ignition/common/script/abc/__init__.py
stubs/stubs/com/inductiveautomation/ignition/common/script/abc/__init__.pyi

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've found 1 issue, and left some high level feedback:

  • In opc.__init__.py, getProperties and getProperty were changed to pass, which removes existing behavior and will break callers; instead, keep the implementations and adjust them for typing (e.g., wrap self._properties.values() in list() and use appropriate typing/casting).
  • If the goal in getProperties was to satisfy the List[BrowseElement.PropertyElement] return type, returning list(self._properties.values()) is preferable to removing the return entirely and will preserve existing runtime behavior.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- In `opc.__init__.py`, `getProperties` and `getProperty` were changed to `pass`, which removes existing behavior and will break callers; instead, keep the implementations and adjust them for typing (e.g., wrap `self._properties.values()` in `list()` and use appropriate typing/casting).
- If the goal in `getProperties` was to satisfy the `List[BrowseElement.PropertyElement]` return type, returning `list(self._properties.values())` is preferable to removing the return entirely and will preserve existing runtime behavior.

## Individual Comments

### Comment 1
<location> `src/com/inductiveautomation/ignition/common/opc/__init__.py:185` </location>
<code_context>
     def getProperties(self):
         # type: () -> List[BrowseElement.PropertyElement]
-        return self._properties.values()
+        pass

     def getProperty(self, id_):
</code_context>

<issue_to_address>
**issue (bug_risk):** Replacing getProperties return with `pass` will break callers expecting a list of PropertyElement

This changes the method from returning a list-like collection of `BrowseElement.PropertyElement` to returning `None`, which will break existing callers (iteration, len, indexing, etc.). If the method is meant to be unimplemented, raise `NotImplementedError`; otherwise it should continue returning the underlying collection (or an appropriate wrapper).
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

def getProperties(self):
# type: () -> List[BrowseElement.PropertyElement]
return self._properties.values()
pass
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue (bug_risk): Replacing getProperties return with pass will break callers expecting a list of PropertyElement

This changes the method from returning a list-like collection of BrowseElement.PropertyElement to returning None, which will break existing callers (iteration, len, indexing, etc.). If the method is meant to be unimplemented, raise NotImplementedError; otherwise it should continue returning the underlying collection (or an appropriate wrapper).

@cesarcoatl cesarcoatl merged commit c426a69 into 8.1 Jan 20, 2026
5 checks passed
@cesarcoatl cesarcoatl deleted the refactor/8.1/fix-type-errors-ty branch January 20, 2026 21:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants