Re: Type hints - am I doing it right?

2023-12-13 Thread Thomas Passin via Python-list

On 12/13/2023 11:17 AM, Mats Wichmann via Python-list wrote:

On 12/13/23 00:19, Frank Millman via Python-list wrote:

I have to add 'import configparser' at the top of each of these 
modules in order to type hint the method.


This seems verbose. If it is the correct way of doing it I can live 
with it, but I wondered if there was an easier way.


Think of import as meaning "make this available in my current (module) 
namespace".


The actual import machinery only runs the first time, that is, if it's 
not already present in the sys.modules dict.


There's also the approach of importing the typing objects conditionally, 
as in this snippet from the Leo Editor 
(https://github.com/leo-editor/leo-editor)


if TYPE_CHECKING:  # pragma: no cover
from leo.core.leoCommands import Commands as Cmdr
from leo.core.leoGui import LeoKeyEvent as Event

Yes, it's more verbose but it makes clear what the intent is.
--
https://mail.python.org/mailman/listinfo/python-list


Request to Review: Tutorial about Python Packaging offering different use case

2023-12-13 Thread Christian Buhtz via Python-list

Hello,

I would like to point to my Python Packaging Tutorial explaining several 
common use cases using minimal demo projects.




I am not an expert and assume that some of my solutions might not be the 
best. So I would appreciate if you can review them.


Background of that project: I am member of FOSS maintainer team and 
prepare the migration of Back In Time 
(https://github.com/bit-team/backintime) from a makefile based 
build-system to a modern Python Build system using pyproject.toml & Co. 
To explore some expect able problems and possible solutions I created 
this minimal examples. I also do plan a tutorial repo about Debian 
Python Packaging using the same approach with minimal examples 
illustrating different use cases.


Thanks in advance,
Christian
--
https://mail.python.org/mailman/listinfo/python-list


TLS support for SysLogHandler (currently in pypi)

2023-12-13 Thread A Tammy via Python-list
Hi all,
  I've been trying to add TLS over TCP support to the core SysLogHandler
and currently have a working example package on PyPI -
https://pypi.org/project/tlssysloghandler/#usage . The package works as
a drop-in replacement for SysLogHandler, trying to support the original
options and extends the class by allowing TLS as well.

I'm hoping people find it useful enough and if possible it can be added
to the SysLogHandler class itself.

The discussion on the forums for ideas is at
https://discuss.python.org/t/allow-tls-configuration-for-sysloghandler/40785/6

A bit of background, for people who don't want to click links

> The syslog handler doesn’t have support for sending logs to a TLS syslog 
> address. The acceptance of TLS for logging is evident by current presence of 
> the SMTP log handler which supports the secure parameter. Modern syslog 
> servers now have support for TLS listeners - rsyslog (the default on ubuntu) 
> - RSyslog Documentation - rsyslog and syslog-ng - 
> https://www.syslog-ng.com/technical-documents/doc/syslog-ng-open-source-edition/3.16/mutual-authentication-using-tls.
> 
> The implementation could be done by implementing the TLS configuration inside 
> the SysLogHandler, or allowing the user to pre-configure the TLS socket by 
> doing the wrapping themselves and only passing final the socket to 
> SysLogHandler.
> 
> There are a couple of unmaintained pypi packages that tried to make a TLS 
> syslog handler but don’t seem to have been maintained for a long time. For a 
> feature like this, it makes sense to have it in core python rather than an 
> unmaintained package.


Feedback and bug reports are very welcome.

Thanks,
Tammy
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Type hints - am I doing it right?

2023-12-13 Thread Mats Wichmann via Python-list

On 12/13/23 00:19, Frank Millman via Python-list wrote:

I have to add 'import configparser' at the top of each of these modules 
in order to type hint the method.


This seems verbose. If it is the correct way of doing it I can live with 
it, but I wondered if there was an easier way.


Think of import as meaning "make this available in my current (module) 
namespace".


The actual import machinery only runs the first time, that is, if it's 
not already present in the sys.modules dict.

--
https://mail.python.org/mailman/listinfo/python-list


[Python-announce] Announcement: TLSSysLogHandler added on PyPI

2023-12-13 Thread epsilon--- via Python-announce-list
A new package for extending SysLogHandler with TLS support has been added on 
PyPI [1].
Modern syslog servers such as rsyslog, syslog-ng and OpenBSD's syslogd have TLS 
support for secure remote logging. Unfortunately the core python SysLogHandler 
does not have this functionality yet.
TLSSysLogHandler extends the SysLogHandler instead of a re-implementation and 
allows specifying a new "secure" parameter, which enables using TLS with TCP. 
The hope is to get TLS functionality into core SysLogHandler after this package 
is stable.
The discussion is present on the forum's [2].

Best,
Aisha

[1] https://pypi.org/project/tlssysloghandler/
[2] https://discuss.python.org/t/allow-tls-configuration-for-sysloghandler/40785
___
Python-announce-list mailing list -- python-announce-list@python.org
To unsubscribe send an email to python-announce-list-le...@python.org
https://mail.python.org/mailman3/lists/python-announce-list.python.org/
Member address: arch...@mail-archive.com


[Python-announce] ANN: A new version (0.5.2) of python-gnupg has been released.

2023-12-13 Thread Vinay Sajip via Python-announce-list
What Changed?=
This is an enhancement and bug-fix release, and all users are encouraged to 
upgrade.

Brief summary:

* Fix #228: Clarify documentation for encryption/decryption.

* Make I/O buffer size configurable via buffer_size attribute on a GPG instance.

This release [2] has been signed with my code signing key:

Vinay Sajip (CODE SIGNING KEY) 
Fingerprint: CA74 9061 914E AC13 8E66 EADB 9147 B477 339A 9B86

Recent changes to PyPI don't show the GPG signature with the download links.
An alternative download source where the signatures are available is at [4].
The source code repository is at [1].
Documentation is available at [5].

As always, your feedback is most welcome (especially bug reports [3],
patches and suggestions for improvement, or any other points via this group).

Enjoy!

Cheers

Vinay Sajip

[1] https://github.com/vsajip/python-gnupg
[2] https://pypi.org/project/python-gnupg/0.5.2
[3] https://github.com/vsajip/python-gnupg/issues
[4] https://github.com/vsajip/python-gnupg/releases/
[5] https://docs.red-dove.com/python-gnupg/



___
Python-announce-list mailing list -- python-announce-list@python.org
To unsubscribe send an email to python-announce-list-le...@python.org
https://mail.python.org/mailman3/lists/python-announce-list.python.org/
Member address: arch...@mail-archive.com


[Python-announce] Announcement: distlib 0.3.8 released on PyPI

2023-12-13 Thread Vinay Sajip via Python-announce-list
Version 0.3.8 of distlib has recently been released on PyPI [1]. For newcomers, 
distlib is a library of packaging functionality which is intended to be usable 
as the basis for third-party packaging tools.
The main changes in this release are as follows:

* Fix #204: use symlinks in venv creation during test.

* Fix #208: handle deprecation removals in Python 3.13.

* Fix #209: use legacy version implementation for Python versions.

A more detailed change log is available at [2].

Please try it out, and if you find any problems or have any suggestions for 
improvements, please give some feedback using the issue tracker at [3].

Regards,

Vinay Sajip

[1] https://pypi.org/project/distlib/0.3.8/
[2] 
https://distlib.readthedocs.io/en/latest/overview.html#change-log-for-distlib
[3] https://github.com/pypa/distlib/issues/new/choose
___
Python-announce-list mailing list -- python-announce-list@python.org
To unsubscribe send an email to python-announce-list-le...@python.org
https://mail.python.org/mailman3/lists/python-announce-list.python.org/
Member address: arch...@mail-archive.com


ANN: A new version (0.5.2) of python-gnupg has been released.

2023-12-13 Thread Vinay Sajip via Python-list
What Changed?=
This is an enhancement and bug-fix release, and all users are encouraged to 
upgrade.

Brief summary:

* Fix #228: Clarify documentation for encryption/decryption.

* Make I/O buffer size configurable via buffer_size attribute on a GPG instance.

This release [2] has been signed with my code signing key:

Vinay Sajip (CODE SIGNING KEY) 
Fingerprint: CA74 9061 914E AC13 8E66 EADB 9147 B477 339A 9B86

Recent changes to PyPI don't show the GPG signature with the download links.
An alternative download source where the signatures are available is at [4].
The source code repository is at [1].
Documentation is available at [5].

As always, your feedback is most welcome (especially bug reports [3],
patches and suggestions for improvement, or any other points via this group).

Enjoy!

Cheers

Vinay Sajip

[1] https://github.com/vsajip/python-gnupg
[2] https://pypi.org/project/python-gnupg/0.5.2
[3] https://github.com/vsajip/python-gnupg/issues
[4] https://github.com/vsajip/python-gnupg/releases/
[5] https://docs.red-dove.com/python-gnupg/



-- 
https://mail.python.org/mailman/listinfo/python-list


Announcement: distlib 0.3.8 released on PyPI

2023-12-13 Thread Vinay Sajip via Python-list
Version 0.3.8 of distlib has recently been released on PyPI [1]. For newcomers, 
distlib is a library of packaging functionality which is intended to be usable 
as the basis for third-party packaging tools.
The main changes in this release are as follows:

* Fix #204: use symlinks in venv creation during test.

* Fix #208: handle deprecation removals in Python 3.13.

* Fix #209: use legacy version implementation for Python versions.

A more detailed change log is available at [2].

Please try it out, and if you find any problems or have any suggestions for 
improvements, please give some feedback using the issue tracker at [3].

Regards,

Vinay Sajip

[1] https://pypi.org/project/distlib/0.3.8/
[2] 
https://distlib.readthedocs.io/en/latest/overview.html#change-log-for-distlib
[3] https://github.com/pypa/distlib/issues/new/choose
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Type hints - am I doing it right?

2023-12-13 Thread Cameron Simpson via Python-list

On 13Dec2023 09:19, Frank Millman  wrote:

I am adding type hints to my code base.

[...]

In the other module I have this -

 def config_database(db_params):

To add a type hint, I now have this -

 def config_database(db_params: configparser.SectionProxy):

To get this to work, I have to add 'import configparser' at the top of 
the module.


I have three separate modules, one for each database, with a subclass 
containing the methods and attributes specific to that database. Each 
one has a connect() method which receives db_params as a parameter. 
Now I have to add 'import configparser' at the top of each of these 
modules in order to type hint the method.


This seems verbose. If it is the correct way of doing it I can live 
with it, but I wondered if there was an easier way.


Not really. It's like any other name - it needs importing if you're 
going to use it.


You can make the hint itself more compact:

from configparser import SectionProxy
...
def config_database(db_params: SectionProxy):

Or you could be a bit more agnostic:

from typing import Mapping
...
def config_database(db_params: Mapping):

since I imagine config_database() would accept any kind of mapping 
(dicts, etc etc).


Cheers,
Cameron Simpson 
--
https://mail.python.org/mailman/listinfo/python-list