Skip to content

Fix/code quality issues#164

Open
anderslindho wants to merge 8 commits into
masterfrom
fix/code-quality-issues
Open

Fix/code quality issues#164
anderslindho wants to merge 8 commits into
masterfrom
fix/code-quality-issues

Conversation

@anderslindho
Copy link
Copy Markdown
Contributor

No description provided.

Comment thread server/tests/unit/cf/test_config.py
Comment on lines -27 to -29
class SourceAddress:
host: str
port: int
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Aren't we losing something here? Previously we had a concrete data structure for the source address. Now we do not.

The same is true I suppose of all the properties: we are going from typed properties to non-typed ones, aren't we?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

We are, yes, but this was just a hack. No instance of the class was ever used.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I tried another way to do the same, maybe you can try it out @jacomago

Comment thread server/pyproject.toml
Comment thread server/recceiver/cf/config.py
Comment thread server/recceiver/application.py
Comment thread server/recceiver/interfaces.py
The field existed on CFConfig but was never read from the config adapter,
so it was permanently hardcoded to "ENGINEER" with no way to override it
per-deployment.
pollreactor.install() was called at module level, replacing the global
Twisted reactor as a side effect of any import of recceiver.application.
This made import order significant in tests and prevented them from
controlling which reactor is used.
Three identical if-self.cancelled / raise CancelledError blocks were
scattered through _update_channelfinder with slightly inconsistent
messages. Collects the pattern into one place so the cancellation
contract is visible and the checks read as one-liners.
…tion

CommitTransaction was defined in interfaces.py and used as a type
annotation in processor.py, but was never constructed anywhere — the
actual runtime value passed is always a Transaction (duck-typed via
ITransaction). The annotation was a dead end for any reader following
the type.

Remove CommitTransaction and SourceAddress (only used by CommitTransaction),
extend ITransaction with the aliases/initial/connected attributes that
were also defined on CommitTransaction, and annotate processor methods
with interfaces.ITransaction to match the real call contract.
- Drop (object) bases on Transaction and CollectionSession
- Rename self.T/_ping_timer in CastReceiver and self.T/_flush_deadline,
  self.C/_commit_chain in CollectionSession — the same name T carried
  different types in the two classes, making the code harder to follow
- Convert remaining .format() strings to f-strings throughout
Rename the module-level logger from _log to log in all recceiver modules
so that ruff's G (flake8-logging-format) rules can detect logging calls
by variable name. In application.py, the existing twisted.python.log
import is aliased to twisted_log to avoid the name collision.

Convert all logging calls that used f-strings or str.format to use
%-style lazy formatting, and enable the G ruleset in ruff so regressions
are caught automatically.
@anderslindho anderslindho force-pushed the fix/code-quality-issues branch from 0360a13 to 16ea37f Compare May 13, 2026 13:36
Eliminates the duplicated "Protocol error! %s" literal that Sonar flagged
as a high-priority code smell (three occurrences in recast.py).
…nsaction docs

Annotates Transaction's instance variables and __init__ signature with
concrete types so static analysis tools can check callers.  Also corrects
the stale ITransaction.records_to_add doc (2-tuple, not 3), and narrows
the source_address description to the IAddress duck type it actually is.
@anderslindho anderslindho force-pushed the fix/code-quality-issues branch from 16ea37f to 0e8023d Compare May 13, 2026 13:38
@sonarqubecloud
Copy link
Copy Markdown

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.

3 participants